我正在研究android项目并获得无法加载memtrack模块的错误,无法加载mentrack模块:-2。我从其他链接获得了一些参考,但仍然得到了同样的错误。我运行程序时得到了白屏。
以下是我的代码:
Android.Manifest
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.gaubharat"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="14"
android:targetSdkVersion="22" />
<uses-feature android:glEsVersion="0x00010001" android:required="true" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.example.gaubharat.MainActivity"
android:label="@string/app_name"
android:screenOrientation="portrait" >
>
</activity>
<activity
android:name="com.example.gaubharat.Product"
android:label="@string/app_name"
android:screenOrientation="portrait" >
>
</activity>
<activity
android:name="com.example.gaubharat.Home"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
<!-- Internet Permissions -->
<uses-permission android:name="android.permission.INTERNET" />
Home.java
package com.example.gaubharat;
import java.util.ArrayList;
import java.util.List;
import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;
import org.json.JSONException;
import org.json.JSONObject;
import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.os.AsyncTask;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
public class Home extends Activity implements OnClickListener {
private EditText contactnum, pass;
private Button hlogin, hskip;
// Progress Dialog
private ProgressDialog pDialog;
// JSON parser class
JSONParser jsonParser = new JSONParser();
private static final String LOGIN_URL = "http://localhost/android/login.php";
private static final String TAG_SUCCESS = "success";
private static final String TAG_MESSAGE = "message";
private int count;
private SharedPreferences settings;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
settings = this.getSharedPreferences("MyApp",0);
count = settings.getInt("count", 0);
// selectContentView();
//setContentView(R.layout.login);
// setup input fields
contactnum = (EditText) findViewById(R.id.contactnumber);
pass = (EditText) findViewById(R.id.password);
// setup buttons
hlogin = (Button) findViewById(R.id.login);
hskip = (Button) findViewById(R.id.skip);
}
//private void selectContentView() {
//switch (count) {
// case 1:
// setContentView(R.layout.cti);
// Intent i = new Intent(this, Cti.class);
//startActivity(i);
//finish();
// break;
// case 2:
// setContentView(R.layout.shopdetail);
// break;
// default:
// setContentView(R.layout.login);
// }
// TODO Auto-generated method stub
//}
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
switch (v.getId()) {
case R.id.login:
new AttemptLogin().execute();
break;
case R.id.skip:
Intent i = new Intent(this, MainActivity.class);
startActivity(i);
break;
default:
break;
}
}
class AttemptLogin extends AsyncTask<String, String, String> {
@Override
protected void onPreExecute() {
super.onPreExecute();
pDialog = new ProgressDialog(Home.this);
pDialog.setMessage("Attempting login...");
pDialog.setIndeterminate(false);
pDialog.setCancelable(true);
pDialog.show();
}
@Override
protected String doInBackground(String... args) {
// TODO Auto-generated method stub
// Check for success tag
int success;
String username = contactnum.getText().toString();
String password = pass.getText().toString();
try {
// Building Parameters
List<NameValuePair> params = new ArrayList<NameValuePair>();
params.add(new BasicNameValuePair("username", username));
params.add(new BasicNameValuePair("password", password));
Log.d("request!", "starting");
// getting product details by making HTTP request
JSONObject json = jsonParser.makeHttpRequest(LOGIN_URL, "POST",
params);
Log.d("Login attempt", json.toString());
success = json.getInt(TAG_SUCCESS);
if (success == 1) {
Log.d("Login Successful!", json.toString());
// save user data
setCount(1);
// save user data
SharedPreferences sp = PreferenceManager
.getDefaultSharedPreferences(Home.this);
Editor edit = sp.edit();
edit.putString("username", username);
edit.commit();
Intent intent = new Intent();
intent.setClass(Home.this, MainActivity.class);
startActivity(intent);
Home.this.finish();
return json.getString(TAG_MESSAGE);
} else {
Log.d("Login Failure!", json.getString(TAG_MESSAGE));
return json.getString(TAG_MESSAGE);
}
} catch (JSONException e) {
e.printStackTrace();
}
return null;
}
private void setCount(int count) {
SharedPreferences.Editor e = settings.edit();
e.putInt("count",count);
e.commit();
// TODO Auto-generated method stub
}
protected void onPostExecute(String file_url) {
// dismiss the dialog once product deleted
pDialog.dismiss();
if (file_url != null) {
Toast.makeText(Home.this, file_url, Toast.LENGTH_LONG).show();
}
}
}
}
home.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:background="@drawable/background11"
android:orientation="vertical" >
<ImageView
android:id="@+id/logo"
android:layout_width="match_parent"
android:layout_height="92dp"
android:layout_marginTop="20dp"
android:maxHeight="10dp"
android:maxWidth="10dp"
android:src="@drawable/logo" />
<EditText
android:id="@+id/contactnumber"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="60dp"
android:ems="10"
android:hint="Contact Number"
android:inputType="phone" />
<EditText
android:id="@+id/password"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="30dp"
android:ems="10"
android:hint="Password"
android:inputType="textPassword" >
</EditText>
<Button
android:id="@+id/login"
android:layout_width="92dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="30dp"
android:text="Login" />
<Button
android:id="@+id/skip"
android:layout_width="92dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="30dp"
android:text="Skip" />
</RelativeLayout>