Skip to content

Commit

Permalink
修复编译报"Class versions V1_5 or less must use F_NEW frames" 问题
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelJokAr committed Dec 14, 2020
1 parent 7cd34a1 commit 18ed81c
Show file tree
Hide file tree
Showing 8 changed files with 49 additions and 37 deletions.
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ dependencies {
if (gradle.useLocal) {
implementation project(':library')
} else {
implementation "com.github.jokar:multi-languages:0.1.4"
implementation "com.github.jokar:multi-languages:0.1.5"
}
}

Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ buildscript {
dependencies {
classpath 'com.android.tools.build:gradle:4.1.0'
classpath 'com.github.panpf.bintray-publish:bintray-publish:1.0.0'
classpath "com.github.jokar:multi-languages.plugin:0.1.4"
classpath "com.github.jokar:multi-languages.plugin:0.1.5"
}
}

Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ org.gradle.jvmargs=-Xmx1536m
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
android.enableD8=true
version=0.1.2
version=0.1.5
android.useAndroidX=true
android.enableJetifier=true
3 changes: 2 additions & 1 deletion library/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ if (gradle.useLocal) {
} else {
apply plugin: 'com.github.panpf.bintray-publish'
}

android {
compileSdkVersion 28
buildToolsVersion '28.0.3'
Expand Down Expand Up @@ -32,7 +33,7 @@ if (!gradle.useLocal) {
userOrg = 'a10188755550'
groupId = 'com.github.jokar'
artifactId = 'multi-languages'
publishVersion = "0.1.4"
publishVersion = "$version"
desc = 'android multi language support (support android O+)'
website = 'https://github.com/MichaelJokAr/MultiLanguages'
}
Expand Down
2 changes: 1 addition & 1 deletion plugin/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ if (!gradle.useLocal) {
userOrg = 'a10188755550'
groupId = 'com.github.jokar'
artifactId = 'multi-languages.plugin'
publishVersion = "0.1.4"
publishVersion = "$version"
desc = 'android multi language support (support android O+)'
website = 'https://github.com/MichaelJokAr/MultiLanguages'
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,37 +51,7 @@ class MultiLanguagesTransform extends Transform {
//没有开启返回(默认开启)
if (!pluginExtension.enable) {
// 将输入原封不动的复制到输出
println("+-----------------------------------------------------------------------------+")
println("| Multi Languages Plugin START |")
println("+-----------------------------------------------------------------------------+")
def startTime = System.currentTimeMillis()

def inputs = transformInvocation.inputs
def outputProvider = transformInvocation.outputProvider

inputs.each { TransformInput input ->
//遍历directoryInputs
input.directoryInputs.each { DirectoryInput directoryInput ->
//处理DirectoryInput
def dest = outputProvider.getContentLocation(directoryInput.name,
directoryInput.contentTypes, directoryInput.scopes,
Format.DIRECTORY)
FileUtils.copyDirectory(directoryInput.file, dest)
}
//遍历jarInputs
input.jarInputs.each { JarInput jarInput ->
//处理JarInput
def destJar = outputProvider.getContentLocation(jarInput.name,
jarInput.contentTypes, jarInput.scopes, Format.JAR)
FileUtils.copyFile(jarInput.file, destJar)
}
}

def cost = (System.currentTimeMillis() - startTime) / 1000
println("+-----------------------------------------------------------------------------+")
println("| Multi Languages Plugin END |")
println("| Plugin cost : $cost s |")
println("+-----------------------------------------------------------------------------+")
disablePlugin(transformInvocation)
return
}

Expand Down Expand Up @@ -119,6 +89,37 @@ class MultiLanguagesTransform extends Transform {
println("+-----------------------------------------------------------------------------+")
}

/**
* 不开启插件
* @param transformInvocation
*/
private void disablePlugin(TransformInvocation transformInvocation) {
println("+-----------------------------------------------------------------------------+")
println("| Multi Languages Plugin DISABLED |")
println("+-----------------------------------------------------------------------------+")

def inputs = transformInvocation.inputs
def outputProvider = transformInvocation.outputProvider

inputs.each { TransformInput input ->
//遍历directoryInputs
input.directoryInputs.each { DirectoryInput directoryInput ->
//处理DirectoryInput
def dest = outputProvider.getContentLocation(directoryInput.name,
directoryInput.contentTypes, directoryInput.scopes,
Format.DIRECTORY)
FileUtils.copyDirectory(directoryInput.file, dest)
}
//遍历jarInputs
input.jarInputs.each { JarInput jarInput ->
//处理JarInput
def destJar = outputProvider.getContentLocation(jarInput.name,
jarInput.contentTypes, jarInput.scopes, Format.JAR)
FileUtils.copyFile(jarInput.file, destJar)
}
}
}

void handleDirectoryInput(DirectoryInput directoryInput, TransformOutputProvider outputProvider, boolean isIncremental) {
if (isIncremental) {
File dest = outputProvider.getContentLocation(directoryInput.getName(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ public static void addApplyOverrideConfiguration(ClassWriter cw, String classNam
mv.visitMethodInsn(INVOKEVIRTUAL, "android/content/res/Configuration", "setTo",
"(Landroid/content/res/Configuration;)V", false);
mv.visitLabel(l1);
mv.visitFrame(Opcodes.F_SAME, 0, null, 0, null);
// mv.visitFrame(Opcodes.F_NEW, 0, null, 0, null);
mv.visitVarInsn(ALOAD, 0);
mv.visitVarInsn(ALOAD, 1);
mv.visitMethodInsn(INVOKESPECIAL, "androidx/appcompat/app/AppCompatActivity",
Expand Down
10 changes: 10 additions & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
include ':app', ':plugin', ':library'
gradle.ext {
useLocal = false
if (useLocal) {
plugin_version = "1.0.1"
lib_version = "1.0.1"
} else {
plugin_version = "0.1.2"
lib_version = "0.1.2"
}
}
gradle.ext {
useLocal = true
if (useLocal) {
Expand Down

0 comments on commit 18ed81c

Please sign in to comment.