Last active
August 29, 2015 14:10
-
-
Save konifar/4c708530a18c3ba011bc to your computer and use it in GitHub Desktop.
Androidでメソッド数が65536を超えた時の対処方法 ref: http://qiita.com/konifar/items/d98c78facbaae63badca
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
apply from: 'strip_play_services.gradle' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
com.android.dex.DexException: Cannot merge new index 65576 into a non-jumbo instruction! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
java.lang.IllegalArgumentException: method ID not in [0, 0xffff]: 65536 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pkg: /data/local/tmp/com.konifar | |
Failure [INSTALL_FAILED_DEXOPT] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ git clone https://github.com/mihaip/dex-method-counts.git | |
$ ./gradlew assemble # ビルド | |
$ ./dex-method-counts path/to/app.apk # or .zip or .dex or directory |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Read in 60366 method IDs. | |
<root>: 60366 | |
: 8 | |
android: 10815 | |
accessibilityservice: 6 | |
accounts: 8 | |
animation: 2 | |
app: 351 | |
bluetooth: 2 | |
content: 303 | |
...(略)... | |
com: 39448 | |
...(略)... | |
google: 18513 | |
ads: 165 | |
mediation: 134 | |
admob: 24 | |
customevent: 40 | |
jsadapter: 38 | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-dontwarn com.google.android.gms.** |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// taken from https://gist.github.com/dmarcato/d7c91b94214acd936e42 | |
def toCamelCase(String string) { | |
String result = "" | |
string.findAll("[^\\W]+") { String word -> | |
result += word.capitalize() | |
} | |
return result | |
} | |
afterEvaluate { project -> | |
Configuration runtimeConfiguration = project.configurations.getByName('compile') | |
ResolutionResult resolution = runtimeConfiguration.incoming.resolutionResult | |
// Forces resolve of configuration | |
ModuleVersionIdentifier module = resolution.getAllComponents().find { | |
it.moduleVersion.name.equals("play-services") | |
}.moduleVersion | |
String prepareTaskName = "prepare${toCamelCase("${module.group} ${module.name} ${module.version}")}Library" | |
Task prepareTask = project.tasks.findByName(prepareTaskName) | |
File playServiceRootFolder = prepareTask.explodedDir | |
// Add the stripping to the existing task that extracts the AAR containing the original classes.jar | |
prepareTask.doLast { | |
// First create a copy of the GMS classes.jar | |
copy { | |
from(file(new File(playServiceRootFolder, "classes.jar"))) | |
into(file(playServiceRootFolder)) | |
rename { fileName -> | |
fileName = "classes_orig.jar" | |
} | |
} | |
// Then create a new .jar file containing everything from the first one except the stripped packages | |
tasks.create(name: "stripPlayServices" + module.version, type: Jar) { | |
destinationDir = playServiceRootFolder | |
archiveName = "classes.jar" | |
from(zipTree(new File(playServiceRootFolder, "classes_orig.jar"))) { | |
exclude "com/google/android/gms/actions/**" | |
exclude "com/google/android/gms/appindexing/**" | |
exclude "com/google/android/gms/appstate/**" | |
exclude "com/google/android/gms/analytics/**" | |
exclude "com/google/android/gms/auth/**" | |
exclude "com/google/android/gms/cast/**" | |
exclude "com/google/android/gms/drive/**" | |
exclude "com/google/android/gms/fitness/**" | |
exclude "com/google/android/gms/games/**" | |
exclude "com/google/android/gms/identity/**" | |
exclude "com/google/android/gms/panorama/**" | |
exclude "com/google/android/gms/plus/**" | |
exclude "com/google/android/gms/security/**" | |
exclude "com/google/android/gms/tagmanager/**" | |
exclude "com/google/android/gms/wallet/**" | |
exclude "com/google/android/gms/wearable/**" | |
// exclude "com/google/ads/**" | |
// exclude "com/google/android/gms/ads/**" | |
// exclude "com/google/android/gms/gcm/**" | |
// exclude "com/google/android/gms/location/**" | |
// exclude "com/google/android/gms/maps/**" | |
} | |
}.execute() | |
delete file(new File(playServiceRootFolder, "classes_orig.jar")) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment