2
我已經在Android Studio 2.1中啓用了傑克,使用構建工具版本24 rc3。我開始使用lambda,但是當我嘗試建立搖籃拋出這個錯誤:傑克:方法'空洞<clinit>()'類型中找不到
Execution failed for task ':app:compileDebugJavaWithJack'.
> java.io.IOException: com.android.jack.api.v01.CompilationException: Method 'void <clinit>()' not found in type 'org.dollars_bbs.thedollarscommunity.activities.ChatActivity$ChatFragment$ChatRefresherThread$1$-void_run__LambdaImpl0'
這裏:
public class PasswordActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_password);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
View.OnClickListener c = v->{
TextView t = ((TextView) findViewById(R.id.textView));
assert t != null;
if (equal(t.getText().toString(), "xx")) {
Intent intent = new Intent(getApplicationContext(), MainActivity.class);
//Clears the Stack so that BACK won't lead here.
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | IntentCompat.FLAG_ACTIVITY_CLEAR_TASK);
startActivity(intent);
} else
Snackbar.make(v, getString(R.string.wrong), Snackbar.LENGTH_LONG).setAction("Action", null).show();
};
View b = findViewById(R.id.button);
if(b != null) b.setOnClickListener(c);
}
}
我試圖清理和重新啓動。我不明白爲什麼會出現錯誤,也不能在Google上找到它。
完整的堆棧:
com.android.jack.api.v01.CompilationException: Method 'void <clinit>()' not found in type 'org.dollars_bbs.thedollarscommunity.activities.PasswordActivity$-void_onCreate_android_os_Bundle_savedInstanceState_LambdaImpl0'
at com.android.jack.api.v01.impl.Api01ConfigImpl$Api01CompilationTaskImpl.run(Api01ConfigImpl.java:111)
at com.android.builder.core.AndroidBuilder.convertByteCodeUsingJackApis(AndroidBuilder.java:1931)
at com.android.build.gradle.tasks.JackTask.doMinification(JackTask.java:148)
at com.android.build.gradle.tasks.JackTask.access$000(JackTask.java:73)
at com.android.build.gradle.tasks.JackTask$1.run(JackTask.java:112)
at com.android.builder.tasks.Job.runTask(Job.java:51)
at com.android.build.gradle.tasks.SimpleWorkQueue$EmptyThreadContext.runTask(SimpleWorkQueue.java:41)
at com.android.builder.tasks.WorkQueue.run(WorkQueue.java:223)
at java.lang.Thread.run(Thread.java:745)
Caused by: com.android.jack.lookup.JMethodWithReturnLookupException: Method 'void <clinit>()' not found in type 'org.dollars_bbs.thedollarscommunity.activities.PasswordActivity$-void_onCreate_android_os_Bundle_savedInstanceState_LambdaImpl0'
at com.android.jack.ir.ast.JDefinedClassOrInterface.getMethod(JDefinedClassOrInterface.java:287)
at com.android.jack.ir.ast.JDefinedClassOrInterface.getMethod(JDefinedClassOrInterface.java:298)
at com.android.jack.transformations.FieldInitializer.run(FieldInitializer.java:57)
at com.android.jack.transformations.FieldInitializer.run(FieldInitializer.java:42)
at com.android.sched.scheduler.ScheduleInstance.runWithLog(ScheduleInstance.java:161)
at com.android.sched.scheduler.MultiWorkersScheduleInstance$SequentialTask.process(MultiWorkersScheduleInstance.java:442)
at com.android.sched.scheduler.MultiWorkersScheduleInstance$Worker.run(MultiWorkersScheduleInstance.java:162)
同樣的異常的,除了我沒有得到詳細程度。我只收到消息「執行失敗的任務」:app:compileDebugJavaWithJack' > java.io.IOException:com.android.jack.api.v01.CompilationException:如果您使用的是Android Studio,則無法編譯「 – Paul
@Paul你可以檢查Gradle控制檯。 – EmmanuelMess
是的,這就是我在Gradle控制檯中看到的。我有一種感覺,就像我試圖做同樣的事情一樣(使用lambda),這是同樣的問題。 – Paul