尝试在手机上运行我的应用时,当我尝试从一个活动转到另一个活动时,它的投掷错误Unfortunately app has stopped !
&当我登录Logcat时,我收到以下错误消息......
12-07 03:12:57.958 17518-17518/com.android.mads.madses E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: com.android.mads.madses, PID: 17518
java.lang.NoClassDefFoundError: Failed resolution of: Landroid/support/v7/internal/widget/TintManager;
at android.support.design.widget.TabLayout$TabView.<init>(TabLayout.java:1145)
at android.support.design.widget.TabLayout.createTabView(TabLayout.java:635)
at android.support.design.widget.TabLayout.addTabView(TabLayout.java:669)
at android.support.design.widget.TabLayout.addTab(TabLayout.java:365)
at android.support.design.widget.TabLayout.addTab(TabLayout.java:340)
at android.support.design.widget.TabLayout.setTabsFromPagerAdapter(TabLayout.java:624)
at android.support.design.widget.TabLayout.setupWithViewPager(TabLayout.java:595)
at com.android.mads.madses.RegisterActivity.onCreate(RegisterActivity.java:35)
at android.app.Activity.performCreate(Activity.java:5953)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1128)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2267)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2388)
at android.app.ActivityThread.access$800(ActivityThread.java:148)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1292)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5312)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:901)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:696)
Caused by: java.lang.ClassNotFoundException: Didn't find class "android.support.v7.internal.widget.TintManager" on path: DexPathList[[zip file "/data/app/com.android.mads.madses-2/base.apk"],nativeLibraryDirectories=[/vendor/lib, /system/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
at android.support.design.widget.TabLayout$TabView.<init>(TabLayout.java:1145)
at android.support.design.widget.TabLayout.createTabView(TabLayout.java:635)
at android.support.design.widget.TabLayout.addTabView(TabLayout.java:669)
at android.support.design.widget.TabLayout.addTab(TabLayout.java:365)
at android.support.design.widget.TabLayout.addTab(TabLayout.java:340)
at android.support.design.widget.TabLayout.setTabsFromPagerAdapter(TabLayout.java:624)
at android.support.design.widget.TabLayout.setupWithViewPager(TabLayout.java:595)
at com.android.mads.madses.RegisterActivity.onCreate(RegisterActivity.java:35)
at android.app.Activity.performCreate(Activity.java:5953)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1128)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2267)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2388)
at android.app.ActivityThread.access$800(ActivityThread.java:148)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1292)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5312)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:901)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:696)
Suppressed: java.lang.ClassNotFoundException: android.support.v7.internal.widget.TintManager
at java.lang.Class.classForName(Native Method)
at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
... 22 more
Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack available
有人可以帮忙吗?
代码: Main RegisterActivity (父标签活动)
package com.android.mads.madses;
import android.os.Bundle;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.view.ViewPager;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import java.util.ArrayList;
import java.util.List;
public class RegisterActivity extends AppCompatActivity{
private Toolbar toolbar;
private TabLayout tabLayout;
private ViewPager viewPager;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_register);
toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
viewPager = (ViewPager) findViewById(R.id.viewpager);
setupViewPager(viewPager);
tabLayout = (TabLayout) findViewById(R.id.tabs);
tabLayout.setupWithViewPager(viewPager);
}
private void setupViewPager(ViewPager viewPager) {
ViewPagerAdapter adapter = new ViewPagerAdapter(getSupportFragmentManager());
adapter.addFrag(new LoginInfoFragment(), "LoginInfo");
adapter.addFrag(new PersonalInfoFragment(), "PersonalInfo");
adapter.addFrag(new ContactInfoFragment(), "ContactInfo");
adapter.addFrag(new VechicleInfoFragment(), "VechicleInfo");
viewPager.setAdapter(adapter);
}
class ViewPagerAdapter extends FragmentPagerAdapter {
private final List<Fragment> mFragmentList = new ArrayList<>();
private final List<String> mFragmentTitleList = new ArrayList<>();
public ViewPagerAdapter(FragmentManager manager) {
super(manager);
}
@Override
public Fragment getItem(int position) {
return mFragmentList.get(position);
}
@Override
public int getCount() {
return mFragmentList.size();
}
public void addFrag(Fragment fragment, String title) {
mFragmentList.add(fragment);
mFragmentTitleList.add(title);
}
@Override
public CharSequence getPageTitle(int position) {
return mFragmentTitleList.get(position);
}
}
}
其中一个片段活动(所有其他片段都有相同的代码)
package com.android.mads.madses;
import android.support.v4.app.Fragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
/**
* Created by Administrator on 07-12-2015.
*/
public class VechicleInfoFragment extends Fragment{
public VechicleInfoFragment(){
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
return inflater.inflate(R.layout.fragment_vechicleinfo , container, false);
}
}
登录活动(这时我点击了“没有帐户?在这里注册&#39; app停止了”
package com.android.mads.madses;
import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Intent;
import android.graphics.Paint;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
import com.android.mads.app.AppConfig;
import com.android.mads.app.AppController;
import com.android.mads.helper.SQLiteHandler;
import com.android.mads.helper.SessionManager;
import com.android.volley.Request;
import com.android.volley.Response;
import com.android.volley.VolleyError;
import com.android.volley.toolbox.StringRequest;
import org.json.JSONException;
import org.json.JSONObject;
import java.util.HashMap;
import java.util.Map;
public class LoginActivity extends Activity {
private EditText ed_email, ed_password;
private Button btn_login, btn_newUser;
private ProgressDialog pDialog;
private SessionManager session;
private SQLiteHandler db;
private static final String TAG = LoginActivity.class.getSimpleName();
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_login);
ed_email = (EditText) findViewById(R.id.edtxt_login_email);
ed_password = (EditText) findViewById(R.id.edtxt_login_password);
btn_login = (Button) findViewById(R.id.btn_login);
btn_newUser = (Button) findViewById(R.id.btn_login_newUser);
pDialog = new ProgressDialog(this);
session = new SessionManager(getApplicationContext());
db = new SQLiteHandler(getApplicationContext());
if (session.isLoggedIn()) {
Intent i = new Intent(LoginActivity.this, HomeActivity.class);
startActivity(i);
finish();
}
btn_login.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String email = ed_email.getText().toString();
String password = ed_password.getText().toString();
if (email.isEmpty() || password.isEmpty()) {
Toast.makeText(LoginActivity.this, "Please Enter Details", Toast.LENGTH_LONG);
} else {
checkLogin(email, password);
}
}
});
btn_newUser.setPaintFlags(btn_newUser.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG);
btn_newUser.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent i = new Intent(LoginActivity.this, RegisterActivity.class);
startActivity(i);
finish();
}
});
}
public void checkLogin(final String email, final String password) {
String tag_req = "login_request";
pDialog.setMessage("Logging In...");
showDialog();
final StringRequest strR = new StringRequest(
Request.Method.POST, AppConfig.LOGIN_URL,
new Response.Listener<String>() {
@Override
public void onResponse(String response) {
hideDialog();
try {
JSONObject jsb = new JSONObject(response);
boolean error = jsb.getBoolean("error");
if (!error) {
String uid = jsb.getString("uid");
JSONObject user = jsb.getJSONObject("user");
String fname = user.getString("fname");
String lname = user.getString("lname");
String email = user.getString("email");
String dob = user.getString("dob");
String address = user.getString("address");
String bloodgroup = user.getString("bloodgroup");
String contact1 = user.getString("contact1");
String contact2 = user.getString("contact2");
String vechiclename = user.getString("vechiclename");
String fueltype = user.getString("fueltype");
String mileage = user.getString("mileage");
String created_at = user.getString("created_at");
db.addUser(uid, fname, lname, email, dob,
address, bloodgroup, contact1, contact2,
vechiclename, fueltype, mileage, created_at);
session.setLogin(true);
Intent i = new Intent(LoginActivity.this, HomeActivity.class);
startActivity(i);
finish();
} else {
String error_msg = jsb.getString("error_msg");
Toast.makeText(LoginActivity.this, error_msg, Toast.LENGTH_LONG).show();
}
} catch (JSONException e) {
e.printStackTrace();
}
}
},
new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
Log.d("TAG ", error.getMessage());
}
}
) {
public Map<String, String> getParams() {
Map<String, String> p = new HashMap<String, String>();
p.put("tag", "login");
p.put("email", email);
p.put("password", password);
return p;
}
};
AppController.getmInstance().addToRequestQueue(strR, tag_req);
}
public void showDialog() {
if (!pDialog.isShowing()) {
pDialog.show();
}
}
public void hideDialog() {
if (pDialog.isShowing()) {
pDialog.dismiss();
}
}
}
的build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "com.android.mads.madses"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:design:23.1.1'
compile project (":volley")
}
答案 0 :(得分:7)
我将appcompat-v7降级为:
编译'com.android.support:appcompat-v7:23.1.1'
为:
编译'com.android.support:appcompat-v7:23.1.0'
并且有效。
答案 1 :(得分:2)
更改依赖关系肯定会解决问题,只需添加
<select ng-model="model.selectedCountry" ng-change="countryChanged()"
ng-options="country.CommonName for country in model.Countries track by country.ISO316613LetterCode">
</select>
并将构建工具版本更新为23.0.2
答案 2 :(得分:0)
我将android studio更新为2.0后遇到了类似的异常。 我正在使用设计库来加载标签,当我打开活动时我遇到了异常。所以我做了以下修复问题。
我更新了 Android SDK工具 Android SDK平台工具 Android SDK构建工具 Android支持库
到最新的可用版本,我将以下内容设置为 compileSdkVersion 23 buildToolsVersion“23.0.1”
和 编译'com.android.support:appcompat-v7:23.1.0' 编译'com.android.support:design:23.1.1'
它解决了我的问题。
答案 3 :(得分:-1)
以下是解决此问题需要采取的步骤
compileSdkVersion
版本[在我的情况下为23] compileSdkVersion