Skip to content

Commit be4300a

Browse files
author
tangxiaolv
committed
修复一些已知问题
1 parent e4ec3ff commit be4300a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+160
-218
lines changed

DexKnifePlugin/README.md

Lines changed: 0 additions & 151 deletions
This file was deleted.

DexKnifePlugin/app/.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
/build
2-
2+
maindexlist.txt
33
*.iml

DexKnifePlugin/app/build.gradle

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,4 @@ dependencies {
3737
compile "io.reactivex:rxjava:${RX_JAVA}"
3838
compile "io.reactivex:rxandroid:${RX_ANDROID}"
3939
compile 'com.android.support:multidex:1.0.1'
40-
}
41-
42-
// 要放到第二个dex中的包名前缀 second_dex_package_list.txt
43-
// Set the prefix of package's path in second_dex_package_list.txt
40+
}

DexKnifePlugin/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ buildscript {
66
}
77

88
dependencies {
9-
classpath 'com.android.tools.build:gradle:2.1.2'
10-
classpath 'com.ceabie.dextools:gradle-dexknife-plugin:2.0.0'
9+
classpath 'com.android.tools.build:gradle:2.1.0'
10+
classpath 'com.ceabie.dextools:gradle-dexknife-plugin:2.0.1'
1111
}
1212
}
1313

DexKnifePlugin/gradle-dexknife-plugin/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ uploadArchives {
4040
repositories {
4141
mavenDeployer {
4242
repository(url: uri('../repo'))
43-
pom.version = "2.0.0"
43+
pom.version = "2.0.1"
4444
pom.artifactId = "gradle-dexknife-plugin"
4545
pom.groupId = "com.ceabie.dextools"
4646
}

DexKnifePlugin/gradle-dexknife-plugin/src/main/groovy/com/ceabie/dexknife/ClassFileTreeElement.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
/*
2+
* Copyright (C) 2016 ceabie (https://github.com/ceabie/)
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
116
package com.ceabie.dexknife;
217

318
import org.gradle.api.file.FileTreeElement;

DexKnifePlugin/gradle-dexknife-plugin/src/main/groovy/com/ceabie/dexknife/DexKnifeConfig.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
/*
2+
* Copyright (C) 2016 ceabie (https://github.com/ceabie/)
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
116
package com.ceabie.dexknife;
217

318
import org.gradle.api.tasks.util.PatternSet;

DexKnifePlugin/gradle-dexknife-plugin/src/main/groovy/com/ceabie/dexknife/DexKnifePlugin.groovy

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
/*
2+
* Copyright (C) 2016 ceabie (https://github.com/ceabie/)
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
116
package com.ceabie.dexknife
217

318
import org.gradle.api.Plugin
@@ -53,14 +68,15 @@ public class DexKnifePlugin implements Plugin<Project> {
5368
for (variant in project.android.applicationVariants) {
5469
if (isMultiDexEnabled(variant)) {
5570
if (SplitToolsFor130.isCompat(variant)) {
71+
System.err.println("DexKnife: Compat 1.3.0.");
5672
SplitToolsFor130.processSplitDex(project, variant)
5773
} else if (SplitToolsFor150.isCompat()) {
5874
SplitToolsFor150.processSplitDex(project, variant)
5975
} else {
60-
println("DexKnife Error: Android gradle plugin only < 2.0.0.");
76+
System.err.println("DexKnife Error: DexKnife is not compatible your Android gradle plugin.");
6177
}
6278
} else {
63-
println("DexKnife : MultiDexEnabled is false, it's not work.");
79+
System.err.println("DexKnife : MultiDexEnabled is false, it's not work.");
6480
}
6581
}
6682
}

DexKnifePlugin/gradle-dexknife-plugin/src/main/groovy/com/ceabie/dexknife/DexSplitTools.java

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,20 @@
1+
/*
2+
* Copyright (C) 2016 ceabie (https://github.com/ceabie/)
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
116
package com.ceabie.dexknife;
217

3-
import com.android.builder.Version;
4-
518
import org.gradle.api.Project;
619
import org.gradle.api.file.FileTreeElement;
720
import org.gradle.api.specs.Spec;
@@ -71,28 +84,15 @@ protected static void endDexKnife() {
7184
System.out.println("DexKnife Finished: " + time);
7285
}
7386

74-
static int getAndroidPluginVersion() {
75-
String version = Version.ANDROID_GRADLE_PLUGIN_VERSION;
76-
int size = version.length();
77-
int ver = 0;
78-
for (int i = 0; i < size; i++) {
79-
char c = version.charAt(i);
80-
if (Character.isDigit(c) || c == '.') {
81-
if (c != '.') {
82-
ver = ver * 10 + c - '0';
83-
}
84-
} else {
85-
break;
86-
}
87-
}
88-
89-
return ver;
90-
}
91-
9287
public static boolean processMainDexList(Project project, boolean minifyEnabled, File mappingFile,
9388
File jarMergingOutputFile, File andMainDexList,
9489
DexKnifeConfig dexKnifeConfig) throws Exception {
9590

91+
if (!minifyEnabled && jarMergingOutputFile == null) {
92+
System.out.println("DexKnife Error: jarMerging is Null! Skip DexKnife. Please report All Gradle Log.");
93+
return false;
94+
}
95+
9696
return genMainDexList(project, minifyEnabled, mappingFile, jarMergingOutputFile,
9797
andMainDexList, dexKnifeConfig);
9898
}
@@ -171,7 +171,7 @@ protected static DexKnifeConfig getDexKnifeConfig(Project project) throws Except
171171
getMaindexSpec(dexKnifeConfig.patternSet);
172172
} else {
173173
dexKnifeConfig.useSuggest = true;
174-
System.err.println("DexKnife Warnning: NO SET split Or keep path, it will use Suggest!");
174+
System.err.println("DexKnife Warning: NO SET split Or keep path, it will use Suggest!");
175175
}
176176

177177
dexKnifeConfig.additionalParameters = addParams;
@@ -245,11 +245,11 @@ private static boolean genMainDexList(Project project, boolean minifyEnabled,
245245

246246
ArrayList<String> mainClasses = null;
247247
if (minifyEnabled) {
248-
System.out.println("DexKnife: From Mapping");
248+
System.err.println("DexKnife: From Mapping");
249249
// get classes from mapping
250250
mainClasses = getMainClassesFromMapping(mappingFile, dexKnifeConfig.patternSet, mainCls);
251251
} else {
252-
System.out.println("DexKnife: From Merged Jar: " + jarMergingOutputFile);
252+
System.err.println("DexKnife: From Merged Jar: " + jarMergingOutputFile);
253253
if (jarMergingOutputFile != null) {
254254
// get classes from merged jar
255255
mainClasses = getMainClassesFromJar(jarMergingOutputFile, dexKnifeConfig.patternSet, mainCls);
@@ -275,7 +275,7 @@ private static boolean genMainDexList(Project project, boolean minifyEnabled,
275275
return true;
276276
}
277277

278-
throw new Exception("DexKnife Warnning: Main dex is EMPTY ! Check your config and project!");
278+
throw new Exception("DexKnife Warning: Main dex is EMPTY ! Check your config and project!");
279279
}
280280

281281
private static ArrayList<String> getMainClassesFromJar(
@@ -348,7 +348,7 @@ private static ArrayList<String> getMainClassesFromMapping(
348348
*/
349349
private static HashSet<String> getAdtMainDexClasses(File outputDir) throws Exception {
350350
if (outputDir == null || !outputDir.exists()) {
351-
System.err.println("DexKnife Warnning: Android recommand Main dex is no exist, try run again!");
351+
System.err.println("DexKnife Warning: Android recommand Main dex is no exist, try run again!");
352352
return null;
353353
}
354354

DexKnifePlugin/gradle-dexknife-plugin/src/main/groovy/com/ceabie/dexknife/MultiDexAndroidBuilder.groovy

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,20 @@
1+
/*
2+
* Copyright (C) 2016 ceabie (https://github.com/ceabie/)
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
116
package com.ceabie.dexknife
217

3-
import com.android.build.gradle.internal.pipeline.TransformTask
418
import com.android.build.gradle.internal.transforms.DexTransform
519
import com.android.builder.core.AndroidBuilder
620
import com.android.builder.core.DexOptions

0 commit comments

Comments
 (0)