2016-04-25 100 views
0

我是一个相当的.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 
    } 
} 
+0

显示你的build.gradle文件。那是AndroidAnnotations吗? –

+0

哪一个? Android工作室中有两个 - 用于项目和应用程序模块。 – Storm

+0

应用程序模块一 –

回答