{"id":962,"date":"2023-03-11T19:40:39","date_gmt":"2023-03-11T11:40:39","guid":{"rendered":"https:\/\/www.appblog.cn\/?p=962"},"modified":"2023-04-29T13:29:32","modified_gmt":"2023-04-29T05:29:32","slug":"common-issues-with-building-android-gradle","status":"publish","type":"post","link":"https:\/\/www.appblog.cn\/index.php\/2023\/03\/11\/common-issues-with-building-android-gradle\/","title":{"rendered":"Android Gradle\u6784\u5efa\u5e38\u89c1\u95ee\u9898"},"content":{"rendered":"<h3>ButterKnife attribute value must be constant<\/h3>\n<p>\u5728Project\u7ea7\u7684build.gradle\u4e2d<\/p>\n<p><!-- more --><\/p>\n<pre><code>buildscript {\n    repositories {\n        google()\n        jcenter()\n        maven {\n            url &#039;https:\/\/maven.google.com&#039;\n        }\n    }\n    dependencies {\n        classpath &#039;com.android.tools.build:gradle:3.1.3&#039;\n        \/\/\u6ce8\u610f\u7248\u672c\uff0c\u52a1\u5fc5\u4f7f\u75288.4.0\u7248\u672c\n        classpath &#039;com.jakewharton:butterknife-gradle-plugin:8.4.0&#039;\n    }\n}<\/code><\/pre>\n<p>\u5728Module\u7ea7\u7684build.gradle\u4e2d<\/p>\n<pre><code>apply plugin: &#039;com.android.library&#039;\napply plugin: &#039;com.jakewharton.butterknife&#039;\n\ndependencies {\n    \/\/ButterKnife\u4f9d\u8d56\n    api &#039;com.jakewharton:butterknife:8.8.1&#039;\n    annotationProcessor &#039;com.jakewharton:butterknife-compiler:8.8.1&#039;\n}<\/code><\/pre>\n<h3>Execution failed for task &#8216;:app:compileDebugJavaWithJavac&#8217;<\/h3>\n<p>\u53c2\u8003\uff1a<a target=\"_blank\" rel=\"noopener\" href=\"https:\/\/stackoverflow.com\/questions\/48071618\/execution-failed-for-task-appcompiledebugjavawithjavac-android-studio-3-1-up\">https:\/\/stackoverflow.com\/questions\/48071618\/execution-failed-for-task-appcompiledebugjavawithjavac-android-studio-3-1-up<\/a><\/p>\n<p>\u5982\u679cbuild\u7a97\u53e3\u6ca1\u6709\u8be6\u7ec6\u9519\u8bef\u4fe1\u606f\uff0c\u5219\u5355\u72ec\u6267\u884cgradle\u6784\u5efa\u4efb\u52a1\uff1a<code>Gradle\u7a97\u53e3<\/code> -&gt; <code>Module<\/code> -&gt; <code>Tasks<\/code> -&gt; <code>build<\/code> -&gt; <code>assembleDebug<\/code>\uff0c\u6b64\u65f6\u4f1a\u663e\u793a\u66f4\u8be6\u7ec6\u7684\u9519\u8bef\u4fe1\u606f<\/p>\n<h3>Default interface methods are only supported starting with Android N (&#8211;min-api 24)<\/h3>\n<p>\u53c2\u8003\uff1a<a target=\"_blank\" rel=\"noopener\" href=\"https:\/\/stackoverflow.com\/questions\/49512629\/android-studio-error-default-interface-methods-are-only-supported-starting-with\">https:\/\/stackoverflow.com\/questions\/49512629\/android-studio-error-default-interface-methods-are-only-supported-starting-with<\/a><\/p>\n<p>\u5728Module\u7ea7\u7684build.gradle\u4e2d<\/p>\n<pre><code>android {\n    ...\n    compileOptions {\n        sourceCompatibility JavaVersion.VERSION_1_8\n        targetCompatibility JavaVersion.VERSION_1_8\n    }\n}<\/code><\/pre>\n<h3>Program type already present: android.support.v13.view.DragAndDropPermissionsCompat<\/h3>\n<p>\u5728Module\u7ea7\u7684build.gradle\u4e2d<\/p>\n<pre><code>dependencies {\n    configurations {\n        all*.exclude group: &#039;com.android.support&#039;, module: &#039;support-v13&#039;\n    }\n}<\/code><\/pre>\n<h3>Gradle: \u9519\u8bef: \u7f16\u7801GBK\u7684\u4e0d\u53ef\u6620\u5c04\u5b57\u7b26<\/h3>\n<p>\u5728Module\u7ea7\u7684build.gradle\u4e2d<\/p>\n<pre><code>apply plugin: &#039;java&#039;\n\ntasks.withType(JavaCompile) {\n    options.encoding = &quot;UTF-8&quot;\n}\n\nsourceCompatibility = &quot;1.8&quot;\ntargetCompatibility = &quot;1.8&quot;<\/code><\/pre>\n<pre><code>apply plugin: &#039;android&#039;\n\ntasks.withType(JavaCompile) {\n    options.encoding = &quot;UTF-8&quot;\n}<\/code><\/pre>\n<h3>\u7f16\u8bd1apk\u5931\u8d25\u63d0\u793a\uff1a\u65e0\u6cd5\u8bbf\u95eeActivityCompatApi23<\/h3>\n<p>1\u3001\u68c0\u67e5\u662f\u5426\u91cd\u590d\u5f15\u7528v4\u5305<br \/>\n2\u3001\u68c0\u67e5\u9879\u76ee\u5f15\u7528\u7684v4\u5305\u4e0e\u7b2c\u4e09\u65b9\u6846\u67b6\u4f9d\u8d56\u7684v4\u5305\u7248\u672c\u662f\u5426\u4e00\u81f4<br \/>\n3\u3001<code>Clean Project<\/code><\/p>\n","protected":false},"excerpt":{"rendered":"<p>ButterKnife attribute value must be constant \u5728Project\u7ea7\u7684 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[202],"tags":[64],"class_list":["post-962","post","type-post","status-publish","format-standard","hentry","category-android-build","tag-gradle"],"_links":{"self":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/962","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/comments?post=962"}],"version-history":[{"count":0,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/962\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/media?parent=962"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/categories?post=962"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/tags?post=962"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}