1. 程式人生 > >Android Studio解決unspecified on project app resolves to an APK archive which is not supported

Android Studio解決unspecified on project app resolves to an APK archive which is not supported

class resolv -s error support ive repl size projects

出現該問題unspecified on project app resolves to an APK archive which is not supported as a compilation dependency的情形可能是:創建了兩個Module,其中一個Module依賴另一個Module而導致了出現該問題;

如果在Android Studio中,有ModuleA和ModuleB,我們希望ModuleA依賴ModuleB,運行時候可能會出現該問題,查看被依賴的ModuleB的build.gradle,裏面可以看到:

  1. apply plugin: ‘com.android.application‘

這句話告訴了Gradle將ModuleB編譯稱為application,也就是apk,這就是問題的所在;

解決方法:將上面該句改為:

  1. apply plugin: ‘com.android.library‘

此時,Gradle將編譯稱為一個Library,也就是庫,運行之後,如果出現這個問題:Error:Library projects cannot set applicationId. applicationId is set to ‘package_name‘ in default config.,那是因為一個庫不允許設置applicationId,需要將builde.gradle — android — defaultConfig中的applicationId刪除;

如果說,我們ModuleB仍然需要生成apk,則我們需要將其中公共的代碼放到一個Module,作為一個support的庫;

http://stackoverflow.com/questions/27536491/how-to-import-android-project-as-library-and-not-compile-it-as-apk-android-stud

Android Studio解決unspecified on project app resolves to an APK archive which is not supported