[英]RoboGuice Error: Didn't find class “AnnotationDatabaseImpl” on path
Trying to get a simple app to run with roboguice but encountering this error: Didn't find class "AnnotationDatabaseImpl" on path:
Looks like a lot of people get this error, and none of the solutions seem to work for me. 试图使一个简单的应用程序与roboguice一起运行,但是遇到此错误: Didn't find class "AnnotationDatabaseImpl" on path:
似乎很多人都遇到了该错误,而且没有一种解决方案适合我。 All I have done is taken the AndroidStudio blank app template. 我所要做的只是采用AndroidStudio空白应用程序模板。 MainActivity.java: MainActivity.java:
package com.example.temp.robotest;
import android.os.Bundle;
import roboguice.RoboGuice;
import roboguice.util.RoboContext;
import java.util.HashMap;
import java.util.HashMap;
import java.util.Map;
import com.google.inject.Key;
import roboguice.activity.RoboActionBarActivity;
public class MainActivity extends RoboActionBarActivity implements RoboContext {
protected HashMap<Key<?>, Object> scopedObjects;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
public Map<Key<?>, Object> getScopedObjectMap() {
return this.scopedObjects;
}
}
And my gradle: 和我的gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 24
buildToolsVersion "24.0.0"
defaultConfig {
applicationId "com.example.temp.robotest"
minSdkVersion 23
targetSdkVersion 24
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:24.0.0'
compile 'org.roboguice:roboguice:3.0'
provided 'org.roboguice:roboblender:3.0'
}
Replacing line 14 in MainActivity.java with //public class MainActivity extends AppCompatActivity implements RoboContext {
and the app runs. 用//public class MainActivity extends AppCompatActivity implements RoboContext {
替换MainActivity.java中的第14行, //public class MainActivity extends AppCompatActivity implements RoboContext {
并且该应用程序运行。 But I wish to use roboguice. 但我希望使用roboguice。 Any thoughts? 有什么想法吗?
Replacing provided 'org.roboguice:roboblender:3.0'
with apt 'org.roboguice:roboblender:3.0'
worked for me. 将provided 'org.roboguice:roboblender:3.0'
替换provided 'org.roboguice:roboblender:3.0'
对我apt 'org.roboguice:roboblender:3.0'
。
You have to enable the com.neenbedankt.android-apt gradle plugin by adding 您必须通过添加启用com.neenbedankt.android-apt gradle插件
apply plugin: 'com.neenbedankt.android-apt'
to your build.gradle from the app module and 从应用模块转到build.gradle
buildscript {
/.../
dependencies {
/.../
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.4'
}
}
to your build.gradle of the project. 到项目的build.gradle。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.