alibaba / freeline

A super fast build tool for Android, an alternative to Instant Run
https://www.freelinebuild.com/
BSD 3-Clause "New" or "Revised" License
5.48k stars 623 forks source link

runtime的appcompact版本高于主工程的appcompact版本,导致编译出错 #20

Closed msdx closed 8 years ago

msdx commented 8 years ago

不使用freeline时正常,由于使用freeline加了compile 'com.antfortune.freeline:runtime:0.5.0'时编译失败,信息如下:

/workspace/project/coupon-manager/app/build/intermediates/res/merged/Develop/debug/values-v23/values-v23.xml:3: AAPT: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.Button.Inverse'.

/workspace/project/coupon-manager/app/build/intermediates/res/merged/Develop/debug/values-v23/values-v23.xml:18: AAPT: Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.Button.Colored'.

下面是使用freeline所作的修改:

diff --git a/app/build.gradle b/app/build.gradle
index bc1fff5..db1d354 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -1,4 +1,5 @@
 apply plugin: 'com.android.application'
+apply plugin: 'com.antfortune.freeline'

 android {
     compileSdkVersion 22
@@ -64,6 +65,9 @@ android {
         abortOnError false
     }

+    freeline {
+        hack true
+    }
 }

 apply plugin: 'bugly'
@@ -120,6 +124,8 @@ dependencies {

     // Material Date Time Picker
     compile 'com.wdullaer:materialdatetimepicker:2.4.0'
+    //freeline
+    compile 'com.antfortune.freeline:runtime:0.5.0'
 }

 apply plugin: 'fir'
diff --git a/app/src/main/java/com/parkingwang/business/WangApplication.java b/app/src/main/java/com/parkingwang/business/WangApplication.java
index f115449..3aaea98 100644
--- a/app/src/main/java/com/parkingwang/business/WangApplication.java
+++ b/app/src/main/java/com/parkingwang/business/WangApplication.java
@@ -3,6 +3,7 @@ package com.parkingwang.business;
 import android.app.Application;
 import android.content.Intent;

+import com.antfortune.freeline.FreelineCore;
 import com.github.yoojia.fast.AppSessionManager;
 import com.github.yoojia.fast.utils.Configurator;
 import com.github.yoojia.next.lang.QuantumObject;
@@ -31,6 +32,7 @@ public class WangApplication extends Application {
     @Override
     public void onCreate() {
         super.onCreate();
+        FreelineCore.init(this);
         LeakCanary.install(this);
diff --git a/build.gradle b/build.gradle
index 80e4381..97a96cd 100644
--- a/build.gradle
+++ b/build.gradle
@@ -15,6 +15,7 @@ buildscript {
         classpath 'com.android.tools.build:gradle:2.2.0-beta1'
         classpath 'com.tencent.bugly:symtabfileuploader:1.3.9'
         classpath 'com.githang:fir:0.1.1'
+        classpath 'com.antfortune.freeline:gradle:0.5.2'
     }
 }
lomanyong commented 8 years ago

@msdx 运行python freeline.py的时候报的错误是吗?

msdx commented 8 years ago

加上该依赖之后使用python或者是使用gradlew都会报错。

lomanyong commented 8 years ago

@msdx 麻烦提供一下gradlew编译报错的详细日志可以吗?

msdx commented 8 years ago

日志如下:

:app:prepareComSquareupLeakcanaryLeakcanaryAndroid14Beta2Library UP-TO-DATE
:app:prepareComTencentBuglyCrashreport220Library UP-TO-DATE
:app:prepareComWdullaerMaterialdatetimepicker240Library UP-TO-DATE
:app:prepareIoReactivexRxandroid110Library UP-TO-DATE
:app:prepareJpWasabeefRecyclerviewAnimators130Library UP-TO-DATE
:app:prepareDevelopDebugDependencies
:app:compileDevelopDebugAidl UP-TO-DATE
:app:compileDevelopDebugRenderscript UP-TO-DATE
:app:generateDevelopDebugBuildConfig UP-TO-DATE
:app:generateDevelopDebugResValues UP-TO-DATE
:app:generateDevelopDebugResources UP-TO-DATE
:app:resourcesInterceptorBeforeMergeDevelopDebugResources
Old file /workspace/project/coupon-manager/app/build/freeline/app/resources_dependencies.json removed.
Save to /workspace/project/coupon-manager/app/build/freeline/app/resources_dependencies.json
:app:mergeDevelopDebugResources UP-TO-DATE
:app:processDevelopDebugManifest UP-TO-DATE
:app:processDevelopDebugResources
/workspace/project/coupon-manager/app/build/intermediates/res/merged/Develop/debug/values-v23/values-v23.xml:3: AAPT: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.Button.Inverse'.

/workspace/project/coupon-manager/app/build/intermediates/res/merged/Develop/debug/values-v23/values-v23.xml:18: AAPT: Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.Button.Colored'.

:app:processDevelopDebugResources FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:processDevelopDebugResources'.
> com.android.ide.common.process.ProcessException: Failed to execute aapt

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED
lomanyong commented 8 years ago

@msdx 这个貌似是你代码的问题,可以参考一下这个链接:http://stackoverflow.com/questions/32092511/resource-error-in-android-studio-after-update-no-resource-found

msdx commented 8 years ago

不,这个锅不能让我来背。我不用freeline时完全没问题,单独加上这句依赖时就编译出错。我的猜想是,应该你们的这个库依赖了版本更高的appcompat,由于gradle对依赖冲突的默认解决策略,这种情况下会采用更高版本的库,因此导致与我公司项目的build tools版本不匹配而出现此问题。那么问题来了,我引入的这个依赖是否依赖了更高版本的appcompat?需要依赖它的原因是什么?等上午去公司我会去求证一下。

msdx commented 8 years ago

早上醒来思路竟如此清晰。刚下看了你们的runtime 的构建脚本,已经证实了我的想法,确实依赖了比我项目高的appcompat(23.0.1),我项目中用的是22.2.1的。接下来我这边的解决方法应该是升级我的buildtools版本与其匹配,当然我的appcompat与其他support库版本也要跟着升以减少as提出的警告。但是你们的runtime,是否真需要对appcompat 23.0.1的依赖吗?

msdx commented 8 years ago

接下来要考虑一下你们的问题了。如果不需要依赖较高的版本,是否需要降一下这个版本以提高友好性?如果不需要这个依赖,把它去掉是否更好?

lomanyong commented 8 years ago

@msdx 感谢指正,确实是这个问题。这个依赖确实不是必须的,下个版本去掉。

msdx commented 8 years ago

@lomanyong 客气了。这两天接手一个离职同事留下来的被维护得乱七八糟的项目,静不下去来去分析问题。早上醒来看到你附的stackoverflow的答案提到的版本问题才一下子想到是这个原因。早上醒来才冷静,到了公司看着项目的代码我又不冷静了T_T