安卓编译的时候依赖包解析不了,老是下载不下来。Faled to resolve: com.squareup.retrofit2:converter-gson:2.3.0

安卓编译的时候依赖包解析不了,老是下载不下来。

安卓编译的时候依赖包解析不了,老是下载不下来。Faled to resolve: com.squareup.retrofit2:converter-gson:2.3.0_第1张图片

E\ldeaProjectsNdrcApp\app\build.gradle
Error: QpenFle
ShowinProiectStructuredala
Faled to resolve: com.squareup.retrofit2:converter-gson:2.3.0
Error: QpenFile
ShowinProiectStructuredalba
Failed to resolve: io.reactivex.njava2:nxandroid:2.0 1
Error: QpenE 
ShownProiectstructuredaloa
Falled to resolve: comlovedise:permissiongen:0.0.6
Error: QoenF e
ShownProiectStucturedalbg
Failed to resolve: com.squareup.okhttp3:loggin ginterceptor:3.8.0
Error: QoenF e
ShowinProiectStructuredaloa
Failed to resolve: com.squareup.retrfit2 :retrofit:2.3.0
Error: 0enFle
ShownProiectStructuredaloa
Failed to resove:.com.github.bumptech.glide:gide:3.7.0
Error: QpenFle
ShownProiectstucturedaloa
Faled to resove: cc.achary:android-support-expercent: 1.0.0
Error: QoenE e
ShowinProiectStructuredalog

解决方法:把 gradle.properties删了,重新编译。

另一个安装时的错误,安装APP成功后,打不开。

FATAL EXCEPTION: main                                                           Process: com.myapplication, PID: 3848                                                               java.lang.RuntimeException: Unable to instantiate application com.myapplication.MyApplication: java.lang.ClassNotFoundException: Didn't find class "com.myapplication1.MyApplication" on path: DexPathList[[zip file "/data/app/com.myapplication1-1/base.apk", zip file "/data/app/com.myapplication1-1/split_lib_slice_8_apk.apk"],nativeLibraryDirectories=[/data/app/com.myapplication1-1/lib/arm, /system/fake-libs, /data/app/com.myapplication1-1/base.apk!/lib/armeabi, /data/app/com.myapplication1-1/split_lib_slice_8_apk.apk!/lib/armeabi, /system/lib, /vendor/lib, /system/vendor/lib, /product/lib]]                                                                     at android.app.LoadedApk.makeApplication(LoadedApk.java:855)                                                                     at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5686)                                                                     at android.app.ActivityThread.-wrap2(ActivityThread.java)                                                                    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1637)                                                                    at android.os.Handler.dispatchMessage(Handler.java:105)                                                                      at android.os.Looper.loop(Looper.java:156)                                                                      at android.app.ActivityThread.main(ActivityThread.java:6577)                                                                      at java.lang.reflect.Method.invoke(Native Method)                                                                      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:942)                                                                      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:832)                                                                   Caused by: java.lang.ClassNotFoundException: Didn't find class "com.myapplication1.MyApplication" on path: DexPathList[[zip file "/data/app/com.myapplication1-1/base.apk", zip file "/data/app/com.myapplication1-1/split_lib_slice_8_apk.apk"],nativeLibraryDirectories=[/data/app/com.myapplication1-1/lib/arm, /system/fake-libs, /data/app/com.myapplication1-1/base.apk!/lib/armeabi, /data/app/com.myapplication1-1/split_lib_slice_8_apk.apk!/lib/armeabi, /system/lib, /vendor/lib, /system/vendor/lib, /product/lib]]                                                                      at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)                                                                     at java.lang.ClassLoader.loadClass(ClassLoader.java:380)                                                                      at java.lang.ClassLoader.loadClass(ClassLoader.java:312)                                                                     at android.app.Instrumentation.newApplication(Instrumentation.java:995)                                                                      at android.app.LoadedApk.makeApplication(LoadedApk.java:849)                                                                     at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5686)?                                                                    at android.app.ActivityThread.-wrap2(ActivityThread.java)?                                                                      at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1637)?                                                                     at android.os.Handler.dispatchMessage(Handler.java:105)?                                                                      at android.os.Looper.loop(Looper.java:156)?                                                                      at android.app.ActivityThread.main(ActivityThread.java:6577)?                                                                    at java.lang.reflect.Method.invoke(Native Method)?                                                                      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:942)?                                                                     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:832

解决方法:在application标签下设置android:allowBackup=”false”

"allowBackup"
        android:name=".MyApplication"
        android:allowBackup="false"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">

PS:AS的Gradle插件默认会启用Manifest Merger Tool,若Library项目中也定义了与主项目相同的属性,则此时会合并失败,并报异常。

解决方法有以下2种:

方法1:在Manifest.xml的application标签下添加tools:replace=”allowBackup”(多个属性用”,”隔开,并且记住在manifest根标签上加入xmlns:tools=”http://schemas.android.com/tools”,否则会找不到namespace)

方法2:在build.gradle根标签上加上useOldManifestMerger true

你可能感兴趣的:(Android)