我是一個相當的.NET人,在Xamarin開發。但是,我已經掌握了一些我想用C#實現的Android Java代碼。問題是該項目是在Eclipse中開發的,然後移植到Android Studio,現在無法編譯。.get()和.put()方法從Eclipse遷移到Android Studio
我已經解決了Gradle的所有問題,但現在我陷入了一些生成的註釋和.put()
和.get()
方法,無法引用。有許多與以下內容類似的東西:
像MySharedPreferences
這樣的常規接口已生成密封(最終)類對應MySharedPreferences_
。這是然後在代碼中使用:
import com.someproject.MySharedPreferences_;
...
public class SomeAndroidClass {
public MySharedPreferences_ prefs;
public SomeMethod() {
String x = prefs.someValue().get;
...
prefs.someValue().put("abc");
}
}
現在,這個不能編譯,因爲不是由Android工作室產生的MySharedPreferences_
類。我試圖擺脫下劃線,並使用MySharedPreferences
接口。但後來我有問題引用.get()
和.put()
方法。請問有人能幫我解決這個問題嗎?
編輯
添加build.gradle
文件:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.0.0'
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
}
}
repositories {
maven { url "http://dl.bintray.com/populov/maven" }
mavenCentral()
mavenLocal()
}
apply plugin: 'com.android.application'
apply plugin: 'android-apt'
def AAVersion = '4.0.0'
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
defaultConfig {
applicationId "com.testproject.smartconfig"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
apt "org.androidannotations:androidannotations:$AAVersion"
compile "org.androidannotations:androidannotations-api:$AAVersion"
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.3.0'
compile 'fr.avianey.com.viewpagerindicator:library:[email protected]'
}
apt {
arguments {
androidManifestFile variant.outputs[0]?.processResources?.manifestFile
}
}
顯示你的build.gradle文件。那是AndroidAnnotations嗎? –
哪一個? Android工作室中有兩個 - 用於項目和應用程序模塊。 – Storm
應用程序模塊一 –