44、
git 端口拒绝解决方案 ssh: connect to host github.com port 22: Connection refused
解决:https://blog.csdn.net/s740556472/article/details/80318886
从ssh连接方式换成https连接方式,依然是先查看当前远程仓库使用的那种协议连接:
$ git remote -v
origin [email protected]:unlimitbladeworks/Data-Struts-Learning.git (fetch)
origin [email protected]:unlimitbladeworks/Data-Struts-Learning.git (push)
移除掉远程仓库的配置
$ git remote rm origin
重新添加新的远程仓库,以https的形式:
git remote add origin https://github.com/unlimitbladeworks/Data-Struts-Learning.git
再次查看:
$ git remote -v
origin https://github.com/unlimitbladeworks/Data-Struts-Learning.git (fetch)
origin https://github.com/unlimitbladeworks/Data-Struts-Learning.git (push)
43、
Caused by: java.lang.IllegalStateException: This Activity already has an action bar supplied by the window decor. Do not request Window.FEATURE_SUPPORT_ACTION_BAR and set windowActionBar to false in your theme to use a Toolbar instead.
解决:
参考:https://my.oschina.net/ocean870227/blog/738442
在style配置文件中加上
<item name="windowActionBar">falseitem>
<item name="windowNoTitle">trueitem>
或者,将parent改为
parent="Theme.AppCompat.Light.NoActionBar"
42、
Android dependency ‘androidx.recyclerview:recyclerview’ has different version for the compile (1.0.0-rc01) and runtime (1.1.0) classpath. You should manually set the same version via DependencyResolution
解决:
Android升级成AndroidX,xml中的控件没有改成AndroidX导致的
41、
java.lang.RuntimeException: Unable to get provider android.support.v4.content.FileProvider: java.lang.ClassNotFoundException: Didn't find class "android.support.v4.content.FileProvider" on path: DexPathList[[zip file "/data/app/com.hi.world.mq-ifYt2PX7TqKZzVF7WTF7mQ==/base.apk"],nativeLibraryDirectories=[/data/app/com.hi.world.mq-ifYt2PX7TqKZzVF7WTF7mQ==/lib/arm64, /system/lib64, /product/lib64]]
解决:参考:https://stackoverflow.com/questions/50624510/classnotfoundexception-didnt-find-class-android-support-v4-content-fileprovid
40、
java.lang.IndexOutOfBoundsException: Inconsistency detected.
这是google官方bug。这是recyclerview内部进行数据重设置的时候布局刷新出现了问题,这个问题我们只能去捕获这个异常,然后留给Google去解决。
java.lang.IndexOutOfBoundsException: Inconsistency detected. Invalid item position 0(offset:0).state:479 android.support.v7.widget.RecyclerView{8cbd42c VFED..... ......I. 0,0-0,0 #7f08011a app:id/recyclerView}, adapter:com.hi.world.mq.adapter.AnalyzeResultShowAdapter@f76eef5, layout:android.support.v7.widget.LinearLayoutManager@8f0948a, context:com.hi.world.mq.AnalyzeShowActivity@586eb36
at android.support.v7.widget.RecyclerView$Recycler.tryGetViewHolderForPositionByDeadline(RecyclerView.java:5923)
at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:5858)
at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:5854)
at android.support.v7.widget.LinearLayoutManager$LayoutState.next(LinearLayoutManager.java:2230)
at android.support.v7.widget.LinearLayoutManager.layoutChunk(LinearLayoutManager.java:1557)
at android.support.v7.widget.LinearLayoutManager.fill(LinearLayoutManager.java:1517)
at android.support.v7.widget.LinearLayoutManager.onLayoutChildren(LinearLayoutManager.java:612)
at android.support.v7.widget.RecyclerView.dispatchLayoutStep2(RecyclerView.java:3924)
at android.support.v7.widget.RecyclerView.onMeasure(RecyclerView.java:3336)
at android.view.View.measure(View.java:24834)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6968)
at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1552)
at android.widget.LinearLayout.measureVertical(LinearLayout.java:842)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:721)
at android.view.View.measure(View.java:24834)
at android.support.v4.view.ViewPager.onMeasure(ViewPager.java:1638)
at android.view.View.measure(View.java:24834)
at android.widget.RelativeLayout.measureChildHorizontal(RelativeLayout.java:735)
at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:481)
at android.view.View.measure(View.java:24834)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6968)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:194)
at android.support.v7.widget.ContentFrameLayout.onMeasure(ContentFrameLayout.java:143)
at android.view.View.measure(View.java:24834)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6968)
at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1552)
at android.widget.LinearLayout.measureVertical(LinearLayout.java:842)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:721)
at android.view.View.measure(View.java:24834)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6968)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:194)
at android.view.View.measure(View.java:24834)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6968)
at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1552)
at android.widget.LinearLayout.measureVertical(LinearLayout.java:842)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:721)
at android.view.View.measure(View.java:24834)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6968)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:194)
at com.android.internal.policy.DecorView.onMeasure(DecorView.java:773)
at android.view.View.measure(View.java:24834)
at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:3244)
at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1999)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2304)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1887)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:8042)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:969)
at android.view.Choreographer.doCallbacks(Choreographer.java:793)
at android.view.Choreographer.doFrame(Choreographer.java:728)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:954)
2021-04-27 16:38:04.694 332-332/com.hi.world.mq E/AndroidRuntime: at android.os.Handler.handleCallback(Handler.java:883)
at android.os.Handler.dispatchMessage(Handler.java:100)
at android.os.Looper.loop(Looper.java:224)
at android.app.ActivityThread.main(ActivityThread.java:7561)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:539)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:995)
2021-04-27 16:38:04.727 526-563/? E/libPowerHal: perfLockRel handle:4835
2021-04-27 16:38:04.735 1299-1421/? E/InputDispatcher: channel '825da0b com.hi.world.mq/com.hi.world.mq.AnalyzeShowActivity (server)' ~ Channel is unrecoverably broken and will be disposed!
2021-04-27 16:38:04.735 1299-1421/? E/InputDispatcher: channel 'cd3d385 正在分析,请稍后... (server)' ~ Channel is unrecoverably broken and will be disposed!
2021-04-27 16:38:04.735 1299-1421/? E/InputDispatcher: channel 'e798036 com.hi.world.mq/com.dj.case_record_choose.activity.Case_MainActivity (server)' ~ Channel is unrecoverably broken and will be disposed!
2021-04-27 16:38:04.740 1299-1421/? E/InputDispatcher: channel '1918c72 com.hi.world.mq/com.hi.world.mq.MainActivity (server)' ~ Channel is unrecoverably broken and will be disposed!
2021-04-27 16:38:04.816 877-877/? E/com.hi.world.m: Unknown bits set in runtime_flags: 0x8000
2021-04-27 16:38:04.998 672-865/? E/Light: AmbienteLight: 551.000000
2021-04-27 16:38:05.125 877-877/com.hi.world.mq E/ARouter::: InstantRun support error, com.android.tools.fd.runtime.Paths
2021-04-27 16:38:05.664 672-865/? E/Light: AmbienteLight: 549.000000
2021-04-27 16:38:06.001 672-865/? E/Light: AmbienteLight: 551.000000
2021-04-27 16:38:06.260 877-929/com.hi.world.mq E/gralloc: Arm Module v1.0
2021-04-27 16:38:06.261 877-929/com.hi.world.mq E/ion: ioctl c0044901 failed with code -1: Invalid argument
2021-04-27 16:38:06.338 877-877/com.hi.world.mq E/MainActivity: 服务与活动成功连接
参考1
参考2
// 原本的代码,偶尔会闪退的
LinearLayoutManager linearLayoutManager = new LinearLayoutManager(requireActivity());
recyclerView.setLayoutManager(linearLayoutManager);
// 改进后的代码,稳定不闪退
LinearLayoutManager mLayoutManager=new XLinearLayoutManager(requireActivity(), LinearLayoutManager.VERTICAL, false);
recyclerView.setLayoutManager(mLayoutManager);
// 自定义内部类XLinearLayoutManager
public class XLinearLayoutManager extends LinearLayoutManager {
public XLinearLayoutManager(Context context) {
super(context);
}
public XLinearLayoutManager(Context context, int orientation, boolean reverseLayout) {
super(context, orientation, reverseLayout);
}
public XLinearLayoutManager(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
super(context, attrs, defStyleAttr, defStyleRes);
}
@Override
public void onLayoutChildren(RecyclerView.Recycler recycler, RecyclerView.State state) {
try {
super.onLayoutChildren(recycler, state);
} catch (IndexOutOfBoundsException e) {
Log.e("bug", "crash in RecyclerView");
}
}
}
39、
Unknown host ‘jcenter.bintray.com’. You may need to adjust the proxy setting
解决办法:
只要在项目项目build.gradle文件中添加maven { url"https://jitpack.io"}
即可。最好加在jcenter()
前面
buildscript {
repositories {
google()
maven {url"https://jitpack.io"}
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.3.0'
}
}
allprojects {
repositories {
google()
maven {url"https://jitpack.io"}
jcenter()
}
}
38、
Manifest merger failed : Attribute application@theme value=(@style/Theme.Justtest) from AndroidManifest.xml:11:9-46
is also present at [com.github.Zenera0301:FreehandsComponents:0.4.0] AndroidManifest.xml:18:9-54 value=(@style/Theme.CaseRecordChoose).
Suggestion: add 'tools:replace="android:theme"' to <application> element at AndroidManifest.xml:5:5-19:19 to override.
解决办法已经在错误的提示里了:
就是添加:
tools:replace=“android:theme”
在Menifest文件中。
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.dj.justtest">
<application tools:replace="android:theme"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.Justtest">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
intent-filter>
activity>
application>
manifest>
37、
Execution failed for task ':app:multiDexListDebug'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
> Error while merging dex archives:
Type com.dj.caserecordchoose.DataBinderMapperImpl$InnerLayoutIdLookup is defined multiple times: D:\Work\Study\Android\TEST1\UI\CaseRecordChoose\CaseRecordChoose\build\intermediates\runtime_library_classes_jar\debug\classes.jar:com/dj/caserecordchoose/DataBinderMapperImpl$InnerLayoutIdLookup.class, D:\Work\Study\Android\TEST1\UI\CaseRecordChoose\app\build\intermediates\javac\debug\classes\com\dj\caserecordchoose\DataBinderMapperImpl$InnerLayoutIdLookup.class
Learn how to resolve the issue at https://developer.android.com/studio/build/dependencies#duplicate_classes.
这个问题不好找真正的原因,直到我搜索了Type com.dj.caserecordchoose.BuildConfig is defined multiple times
发现了这个回答https://blog.csdn.net/mp624183768/article/details/106252990
问题解决:
检查不同的程序块里面有一样的包名。
修改其中一个即可。注意使用 批量替换 时应当注意不要全部替换了,不然还会是一样 。
36、
Execution failed for task ‘:app:mergeDexDebug’.
解决:添加multiDexEnabled true
dependencies {
implementation 'com.android.support:multidex:1.0.3' //enter the latest version
}
android {
defaultConfig {
multiDexEnabled true
}
}
35、
错误:
compileDebugJavaWithJavac
解决方法:
报这个错的原因贼多了。
想要知道具体的错误是什么。
就去File》Setting》Compile的Command-line Options里面输入–debug并确认
再运行一次就可以看到更详细的错误是什么了。
34、
问题:
Error: Activity class {com.xy.vera.sy/com.xy.vera.qhq.MainActivity} does not exist.
解决:
https://stackoverflow.com/questions/20737200/execution-failed-appprocessdebugresources-android-studio/26452895#26452895
33、
Execution failed for task ‘:app:processDebugResources’.
异常信息:
Execution failed for task ':app:processDebugResources'.
> com.android.ide.common.internal.LoggedErrorException: Failed to run command:
E:\Program Files (x86)\Android\android-sdk\build-tools\19.0.0\aapt.exe package -f --no-crunch -I E:\Program Files (x86)\Android\android-sdk\platforms\android-19\android.jar -M E:\Documents\smart-my-job1\app\build\manifests\debug\AndroidManifest.xml -S E:\Documents\smart-my-job1\app\build\res\all\debug -A E:\Documents\smart-my-job1\app\build\assets\debug -m -J E:\Documents\smart-my-job1\app\build\source\r\debug -F E:\Documents\smart-my-job1\app\build\libs\app-debug.ap_ --debug-mode --custom-package com.smartmyjob
Error Code:
-1073741819
解决:
在build.gradle中修改版本
如:buildToolsVersion "21.0.1"
32、
android 安装apk出错-INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION
解決:
将包含错误的多于的xml文件删除即可
31、
异常信息:
Caused by: java.lang.IllegalStateException: This Activity already has an action bar supplied by the window decor. Do not request Window.FEATURE_SUPPORT_ACTION_BAR and set windowActionBar to false in your theme to use a Toolbar instead.
问题原因:
当在activity中调用了setSupportActionBar(toolbar);
解决办法:
增加style,并在AndroidMenifest中调用
增加:
<style name="AppTheme.NoActionBar">
- "windowActionBar"
>false
- "windowNoTitle"
>true
style>
调用:
<application
...
android:theme="@style/AppTheme.NoActionBar"
>
30、
错误: cannot generate view binders java.lang.ClassCastException: android.databinding.tool.expr.IdentifierExpr cannot be cast to android.databinding.tool.expr.StaticIdentifierExpr
将
android:text="@{jniAccessField.num}"
修改为:
android:text="@{String.valueOf(jniAccessField.num)}"
<TextView
android:id="@+id/tv3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@{String.valueOf(jniAccessField.num)}"
app:layout_constraintBottom_toTopOf="@+id/guideline3"
app:layout_constraintEnd_toStartOf="@+id/guideline"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="@+id/guideline2" />
29、
DSL element ‘android.dataBinding.enabled’ is obsolete and has been replaced with ‘android.buildFeatures.dataBinding’.
解决:
从Android Gradle Plugin4.0.0 开始,有一个被称为buildFeatures启用构建功能的模块,所以要使用新的AGP插件启用数据绑定,得改为以下配置:
android {
buildFeatures {
dataBinding true
// for view binding:
// viewBinding true
}
}
28、
java.util.ConcurrentModificationException
原因:对Vector、ArrayList在迭代的时候如果同时对其进行修改就会抛出java.util.ConcurrentModificationException异常
解决方法:
/**
* 将ArrayList数组转换成字符串
* @param arrayList_bytes 需要转换的ArrayList数组
* @return 返回的String类型变量
*/
public static String Arraylist_bytes_2_String(ArrayList<byte[]> arrayList_bytes){
StringBuilder sb = new StringBuilder();
synchronized (arrayList_bytes) { // 为了防止java.util.ConcurrentModificationException错误,在读取的时候修改了列表会报这个错
for (byte[] b :
arrayList_bytes) {
sb.append("\n").append(new String(b));
}
}
return sb.toString();
}
27、
More than one file was found with OS independent path ‘lib/arm64-v8a/libavutil.so’.
意思是加载的so库重复了,那么所有报错误的 .so都选择第一个加载即可:
android {
......
packagingOptions {
pickFirst 'lib/arm64-v8a/libc++_shared.so'
pickFirst 'lib/x86/libc++_shared.so'
pickFirst 'lib/armeabi-v7a/libc++_shared.so'
}
}
26、
执行sh批处理文件报错,原因是文件没有可执行权限
$ sudo ./untitled.sh
Password:
sudo: ./untitled.sh: command not found
给脚本增加可执行权限:
chmod +x untitled.sh
用下列命令查看文件权限
ll untitled.sh # Linux
ls -l untitled.sh # Mac
=============================================== 以下是正叙
1、PopupWindow出现Unable to add window – token null is not valid; is your activity running?
参考1
PopupWindow出现android.view.WindowManager$BadTokenException: Unable to add window – token null is not valid; is your activity running?的异常是因为PopupWindow需要依附在一个创建好的Activity上,那么出现这个异常就说明此时你的Activity还没有创建好,出现这种情况,很可能是在onCreate()或者是onStart()中调用导致的。
2、Android error: failed linking file resources
(1)检查一下自己的XML文件中是不是有问题,十有八九是xml的问题。
一般xml文件名不会变红,要手动点开最近修改的xml文件检查是否有红色报错。
(2)十有一二是版本问题:如果遇到了下面的内容error: resource android:attr/dialogCornerRadius not found.
说明可能是版本问题,
参考1:https://blog.csdn.net/qq_35366269/article/details/89239440
参考2:https://blog.csdn.net/weixin_43465451/article/details/83185112
参考1中的说法是:将当前项目中的build.gradle文件中的targetSdkVersion和compileSdkVersion 的版本改为28:
3、Android Studio提示Failed to resolve: com.android.support.constraint:constraint-layout:1.0.2
参考:https://blog.csdn.net/qq_36317441/article/details/77451570
// compile 'com.android.support.constraint:constraint-layout:1.0.1'
修改为:
implementation "com.android.support.constraint:constraint-layout:1.1.3"
4、
报错信息:
Failed to parse XML in E:\AndroidStudio_Projects\Project5Filed\Field_2019\app\src\main\AndroidManifest.xml
ParseError at [row,col]:[24,5]
Message: expected start or end tag
Affected Modules: app
解决方法:
修改注释方式:
5、错误: 程序包okhttp3不存在
解决方法:
修改app目录下的build.gradle文件中dependencies里面添加下面一句代码,导入这个库就好了
compile 'com.squareup.okhttp3:okhttp:3.4.1'
6、canvas.save(Canvas.ALL_SAVE_FLAG)参数数量不对
解决方法:
canvas.save(Canvas.ALL_SAVE_FLAG);
改为:
canvas.save();
7、fragment 中import androidx.fragment.app.Fragment 和import android.app.Fragment无法相互转换
解决方法:
Android studio 中使用androidx.fragment.app.Fragment实现界面切换,可能会遇到这个问题:
由于将Android studio 版本从2.3版本更新到了3.5版本所以在使用android.support.v4.app.Fragment实现布局切换出现了一些问题,比如说无法导入v4包中的Fragment等问题.
下面我给大家分享一下我自己使用androidx.fragment.app.Fragment实现Fragment界面切换的列子
其实问题都处在使用 FragmentTransaction类进行Fragment页面加载的问题
在V4包中,加载每一个Fragment碎片布局使用的方法如下
首先创建一个fragmentManager对象:
private FragmentManager fragmentManager = null;
this.fragmentManager = getFragmentManager();
然后利用fragmentManager对象创建一个FragmentTransaction对象:
FragmentTransaction transaction = this.fragmentManager.beginTransaction();
最后使用FragmentTransaction中的对象进行Fragment页面布局的加载。
在androidx支持的包中:直接创建FragmentTransaction对象即可,然后调用对象中的方法进行Fragment页面布局的加载
FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
8、Location specified by ndk.dir (xxx) did not contain a valid NDK and and couldn’t be used
导致异常的原因有两个:
1:路径的格式不对(其实一开始就想到这个问题了,我是直接用NotePad++打开的导致没有错误提示)
2:要具体到ndk的版本
解决方法:
打开local.properties,删掉里面的ndk路径那一行即可
9、 java.lang.UnsatisfiedLinkError: No implementation found for int com.baidu.mapsdkplatform.comjni.tools.JNITools.initClass(java.lang.Object, int) (tried Java_com_baidu_mapsdkplatform_comjni_tools_JNITools_initClass and Java_com_baidu_mapsdkplatform_comjni_tools_JNITools_initClass__Ljava_lang_Object_2I)
这是百度地图的问题,去官网下载了最新版本的so库和jar包,so库放到jniLibs文件夹中,jar包放到libs文件夹中,运行即可。
10、
java.lang.RuntimeException: Unable to start activity ComponentInfo
{com.ding.admin.newfieldtest/com.ding.admin.newfieldtest.MainActivity}:
android.view.InflateException:
Binary XML file line #2:
Binary XML file line #2: Error inflating class androidx.constraintlayout.ConstraintLayout
把androidx.constraintlayout.ConstraintLayout换成LinearLayout就行了
11、
Caused by: android.view.InflateException: Binary XML file line #16: Binary XML file line #16: Error inflating class androidx.core.view.ViewPager
Caused by: android.view.InflateException: Binary XML file line #16: Error inflating class androidx.core.view.ViewPager
Caused by: java.lang.ClassNotFoundException: Didn't find class "androidx.core.view.ViewPager" on path: DexPathList[[zip file "/data/app/com.ding.admin.newfieldtest-qqOV5pUaEJpTK0BXHHuxfw==/base.apk"],nativeLibraryDirectories=[/data/app/com.ding.admin.newfieldtest-qqOV5pUaEJpTK0BXHHuxfw==/lib/arm64, /data/app/com.ding.admin.newfieldtest-qqOV5pUaEJpTK0BXHHuxfw==/base.apk!/lib/arm64-v8a, /system/lib64, /vendor/lib64]]at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:125)
解决办法:
androidx.core.view.ViewPager
换成:
androidx.viewpager.widget.ViewPager
控件如下就不报错了:
<androidx.viewpager.widget.ViewPager
android:id="@+id/viewPager"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentTop="true"
android:layout_above="@id/viewGroup"
android:layout_marginBottom="10dp"
>
12、
报错:
java.lang.IllegalArgumentException: Cannot format given Object as a Number
at java.text.DecimalFormat.format(DecimalFormat.java:507)
at java.text.Format.format(Format.java:157)
这句话报的错:mLatitude = new DecimalFormat("#.000000").format(dfArray[Integer.parseInt(strsFromCaller)][0]);
解决:
mLatitude = new DecimalFormat("#.000000").format(dfArray[Integer.parseInt(strsFromCaller)][0]);
给数据加一层保护层,new BigDecimal(),改为:
mLatitude = new DecimalFormat("#.000000").format(new BigDecimal(dfArray[Integer.parseInt(strsFromCaller)][0]));
13、This project uses AndroidX dependencies, but the android.useAndroidX property is not enabled
解决分两步:
若存在进入第二步。
若不存在创建一个同名该文件,并在文件中添加一句org.gradle.jvmargs=-Xmx1536m。
android.useAndroidX=true
android.enableJetifier=true
14、
Cause: d29vzk4ow07wi7.cloudfront.net:443 failed to respond
解决方法:
修改build.gradle文件
添加:
mavenCentral()
repositories {
mavenCentral()
google()
jcenter()
}
allprojects {
repositories {
mavenCentral()
google()
jcenter()
flatDir {
dirs 'libs'
}
}
}
15、
Manifest merger failed with multiple errors, see logs
参考:https://www.liangzl.com/get-article-detail-175677.html
原因:minsdkversion定义为17 小于 library 定义的19,
解决:在主module里面改变build.gradle 的 minsdkversion 改为 19就解决了
16、
java.lang.IllegalStateException: Not allowed to start service Intent
参考:https://blog.csdn.net/shift_wwx/article/details/82258858?utm_source=blogxgwz5
原因:顺利启动service,需要满足下面的条件:
解决:将targetSdkVersion改成25即可。
17、
Android studio ERROR: Failed to resolve: com.android.support.test.espresso:espresso-core:2.2.2
Android studio跑别人的项目,经常会出现这种不匹配的情况。
解决方法:
添加
maven {
url “https://maven.google.com”
}
allprojects {
repositories {
jcenter()
maven {
url "https://maven.google.com"
}
}
}
18、
Keystore file D:\Android\tztx.jks not found for signing config ‘config’.
解决:去build.gradle中将不用的内容注释掉
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
// signingConfig signingConfigs.config
}
// debug {
// signingConfig signingConfigs.config
// }
}
19、
Error: Program type already present: com.alibaba.android.vlayout.BuildConfig
依赖重复问题
(1)
在app的build.gradle中加上一句话:multiDexEnabled true
defaultConfig {
multiDexEnabled true
}
(2)
在app的build.gradle中:
dependencies {
configurations{
all*.exclude group:'com.google.android'
all*.exclude group:'com.alibaba.android'
}
}
configurations{
all*.exclude group:'com.google.android'
all*.exclude group:'com.alibaba.android'
}
(3)参考https://blog.csdn.net/Calvin_zhou/article/details/80880501
maven库搜索方法:
网址:https://mvnrepository.com/search?q=
输入:implementation 'com.alibaba.android:vlayout:1.2.36’中的com.alibaba.android:vlayout:1.2.36
点Vlayout,点1.2.36,下方gradle中:
// https://mvnrepository.com/artifact/com.alibaba.android/vlayout
compile group: 'com.alibaba.android', name: 'vlayout', version: '1.2.36'
20、
The given artifact contains a string literal with a package reference ‘android.support.v4.content’ that cannot be safely rewritten. Libraries using reflection such as annotation processors need to be updated manually to add support for androidx.
参考:https://blog.csdn.net/weixin_39069034/article/details/100600155
(1)安装插件:
(2)添加依赖到项目中:
project依赖
buildscript {
repositories {
mavenCentral()
google()
}
dependencies {
classpath 'com.jakewharton:butterknife-gradle-plugin:10.1.0'
}
}
(3)mouble 依赖
也就是 app 依赖:
头部添加:
apply plugin: 'com.jakewharton.butterknife'
(4)jar 包依赖:
android {
...
// Butterknife requires Java 8.
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
implementation 'com.jakewharton:butterknife:10.1.0'
annotationProcessor 'com.jakewharton:butterknife-compiler:10.1.0'
}
21、
Android Studio——minSdk(API 24) > deviceSdk(API 23)
解决:
在目录中找到app目录下的build.gradle这个文件,将里面的minSdkVersion 改成23,然后会出现蓝色的顶栏提示,点击Sync Now即可。
如果AS找不到手机,确保手机的开发者模式中开启了USB调试。
22、
bash: ./configure: /bin/sh^M: bad interpreter: No such file or directory
configure文件是dos格式,需要转成Unix格式
这时需要使用到vim
vim configure
:set ff=unix
:wq
然后./configure就可以了
23、
在第三方QQ登录的时候,该应用非官方正版应用,请去应用宝下载正版后进行qq登陆。错误码:100044
解决:检查代码里配置的applicationid是否正确。一定要改成约定的那个字符串。丝毫不能有误。
24、
运行git remote add origin [email protected]:bigyellowdindin/qu-hao-qi.git
报错说本地库已经关联了origin的远程库
fatal: remote origin already exists.
解决办法:
(0)可以先 git remote -v
查看远程库信息
(1)先输入$ git remote rm origin
(删除关联的origin的远程库)
(2)再输入$ git remote add origin [email protected]:(github名)/(git项目名).git
就不会报错了!
25、
$ git push -u origin master
To gitee.com:bigyellowdindin/DF.git
! [rejected] master -> master (fetch first)
error: failed to push some refs to '[email protected]:bigyellowdindin/DF.git'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
解决方法:https://blog.csdn.net/dietime1943/article/details/85682688
(1)先拉下来,会自动合并的(不用操心)
git pull origin master
(2)再上传
git push -u origin master
或者如果只有一个人用这个仓库,可以用:git push -u origin master
强行推送