我正在试图弄清楚如何修复我已经移植到android studio的遗留android项目的错误。我希望这对我的build.gradle脚本来说更成问题。类库在编码时可以正常工作,完成后也可以正常工作。
我已经尝试关闭android studio,运行gradlew clean,然后在android studio中重新打开它并且没有用。
我有Car.class,它扩展了RealmObject 其中的setter和getter方法也是
我的gradle app:
apply plugin: 'com.android.application'
android {
compileSdkVersion 24
buildToolsVersion "24.0.0"
defaultConfig {
applicationId "com.ndprwork.cartest"
minSdkVersion 17
targetSdkVersion 24
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
我的添加课程:
package com.ndprwork.cartest;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.Toast;
import io.realm.Realm;
import io.realm.RealmConfiguration;
public class Add extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_add);
final EditText et_car=(EditText)findViewById(R.id.ETcar);
final EditText et_mat=(EditText)findViewById(R.id.ETmat);
final EditText et_model=(EditText)findViewById(R.id.ETmodel);
final CheckBox cb_new=(CheckBox)findViewById(R.id.CBnew);
Button addnew=(Button)findViewById(R.id.bt_addnew);
addnew.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Car car=new Car();
car.setName(et_car.getText().toString());
car.setMatr(et_mat.getText().toString());
car.setModel(et_model.getText().toString());
car.setStat(cb_new.isChecked());
RealmConfiguration config = new RealmConfiguration.Builder(getApplicationContext()).build();
Realm crealm =Realm.getInstance(config);
crealm.beginTransaction();
crealm.copyToRealmOrUpdate(car);
crealm.commitTransaction();
Toast.makeText(Add.this,"Done car added",Toast.LENGTH_SHORT).show();
}
}
);
}
}
LOGINPAGE CLASS:
package com.ndprwork.cartest;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
public class Loginpage extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_loginpage);
Button addnew=(Button)findViewById(R.id.newadd);
addnew.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent in=new Intent(Loginpage.this,Add.class);
startActivity(in);
}
});
}
我的日志:
07-12 16:05:00.537 18135-18135/com.ndprwork.cartest E/dalvikvm: Could not find class 'android.util.ArrayMap', referenced from method com.android.tools.fd.runtime.MonkeyPatcher.pruneResourceCache
07-12 16:05:00.557 18135-18135/com.ndprwork.cartest E/dalvikvm: Could not find class 'android.os.PersistableBundle', referenced from method com.ndprwork.cartest.Loginpage.access$super
07-12 16:05:00.557 18135-18135/com.ndprwork.cartest E/dalvikvm: Could not find class 'android.os.PersistableBundle', referenced from method com.ndprwork.cartest.Loginpage.access$super
07-12 16:05:00.557 18135-18135/com.ndprwork.cartest E/dalvikvm: Could not find class 'android.media.session.MediaController', referenced from method com.ndprwork.cartest.Loginpage.access$super
07-12 16:05:00.557 18135-18135/com.ndprwork.cartest E/dalvikvm: Could not find class 'android.widget.Toolbar', referenced from method com.ndprwork.cartest.Loginpage.access$super
07-12 16:05:00.577 18135-18135/com.ndprwork.cartest E/dalvikvm: Could not find class 'android.app.ActivityManager$TaskDescription', referenced from method com.ndprwork.cartest.Loginpage.access$super
07-12 16:05:00.577 18135-18135/com.ndprwork.cartest E/dalvikvm: Could not find class 'android.app.SharedElementCallback', referenced from method com.ndprwork.cartest.Loginpage.access$super
07-12 16:05:00.577 18135-18135/com.ndprwork.cartest E/dalvikvm: Could not find class 'android.os.PersistableBundle', referenced from method com.ndprwork.cartest.Loginpage.access$super
07-12 16:05:00.587 18135-18135/com.ndprwork.cartest E/dalvikvm: Could not find class 'android.transition.TransitionManager', referenced from method com.ndprwork.cartest.Loginpage.access$super
07-12 16:05:00.597 18135-18135/com.ndprwork.cartest E/dalvikvm: Could not find class 'android.app.SharedElementCallback', referenced from method com.ndprwork.cartest.Loginpage.access$super
07-12 16:05:00.607 18135-18135/com.ndprwork.cartest E/dalvikvm: Could not find class 'android.app.assist.AssistContent', referenced from method com.ndprwork.cartest.Loginpage.access$super
07-12 16:05:00.617 18135-18135/com.ndprwork.cartest E/dalvikvm: Could not find class 'android.view.SearchEvent', referenced from method com.ndprwork.cartest.Loginpage.access$super
07-12 16:05:00.617 18135-18135/com.ndprwork.cartest E/dalvikvm: Could not find class 'android.os.PersistableBundle', referenced from method com.ndprwork.cartest.Loginpage.access$super
07-12 16:05:00.807 18135-18135/com.ndprwork.cartest E/ION: ION_IOC_CUSTOM_GET_CONFIG ioctl Failed. Use default
发生了什么? 我犯了错误吗?