2023-12-06
每次跑模塊工程總是好費勁,都不知道打我這個模塊工程用的是什麼奇葩環境。
PluginsDevProject_Android_1.1.52\androidstudio\AndroidPluginDevSDK_androidStudio\moduleDemo\build.gradle
原版是
dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) compileOnly files('../app/libs/apiEngine v1.1.0.jar') }
我本地打包moduleDemo模塊(aar),會報錯
Execution failed for task ':moduleDemo:javaPreCompileDebug'.
> Could not resolve all files for configuration ':moduleDemo:debugCompileClasspath'.
> Failed to transform file 'apiEngine v1.1.0.jar' to match attributes {artifactType=android-classes, org.gradle.libraryelements=jar, org.gradle.usage=java-runtime}
> Execution failed for IdentityTransform: D:\2023\AndroidPluginDevSDK_androidStudio\app\libs\apiEngine v1.1.0.jar.
> Expecting a file or a directory: D:\2023\AndroidPluginDevSDK_androidStudio\app\libs\apiEngine v1.1.0.jar
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
自己修改成下面的樣子,就不報錯
dependencies { implementation fileTree(dir: '../app/libs', include: ['*.jar']) //compileOnly files('libs/apiEngine v1.1.0.jar') }
或者是把/app/libs/apiEngine v3.0.0.jar複製一份到/moduleDemo/libs下,然後配置改成
dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) //compileOnly files('../app/libs/apiEngine v1.1.0.jar') }
也不報錯。
Cannot fit requested classes in a single dex file (# methods: 66683 > 65536)
解決辦法:在build.gradle配置中加上
android { defaultConfig { // 其他配置項... multiDexEnabled true } }