问题描述
我已经到处寻找答案.我已经找到了许多解决此错误的方法,但是它对我不起作用. 3天前,我才刚开始使用android.到今天为止一切都很好.我收到此错误
I have looked every where for an answer to this. I have found many solutions for this error but it's not working for me. I have just started working with android 3 days ago. It was going great until today. I am getting this error
Installing com.mycompany.myfirstapp
DEVICE SHELL COMMAND: pm install -r "/data/local/tmp/com.mycompany.myfirstapp"
pkg: /data/local/tmp/com.mycompany.myfirstapp
Failure [INSTALL_PARSE_FAILED_MANIFEST_MALFORMED]
我看到的解决方案是关于包装标签/名称中的大写字母.我的没有大写字母,但我仍然遇到错误.这是我的清单:
The solutions I have seen was about a capitol letter in the package tag/name. Mine does not have a capitol letter in it but I am still getting the error.Here is my Manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.mycompany.myfirstapp">
<uses-sdk android:minSdkVersion="7" android:targetSdkVersion="18" />
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".MyActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".DisplayMessageActivity"
android:label="@string/title_activity_display_message"
android:parentActivityName=".MyActivity" >
<meta-data
android:name="android.support.PARENT_ACTIVITY" />
</activity>
</application>
</manifest>
我不确定发生了什么.拜托,我真的很想学习.
I'm not sure what's going on. Please, I really want to learn.
更新
package com.mycompany.myfirstapp;
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.content.Intent;
import android.view.View;
import android.widget.EditText;
public class MyActivity extends AppCompatActivity {
public final static String EXTRA_MESSAGE = "com.mycompany.myfirstapp.MESSAGE";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_my);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.menu_my, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
//noinspection SimplifiableIfStatement
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
public void sendMessage(View view) {
Intent intent = new Intent(this, DisplayMessageActivity.class);
EditText editText = (EditText) findViewById(R.id.edit_message);
String message = editText.getText().toString();
intent.putExtra(EXTRA_MESSAGE, message);
startActivity(intent);
}
}
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
android:layout_height="match_parent" android:orientation="horizontal">
<EditText android:id="@+id/edit_message"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:hint="@string/edit_message" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/button_send"
android:onClick="sendMessage" />
</LinearLayout>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" tools:context=".MyActivity">
<item android:id="@+id/action_settings" android:title="@string/action_settings"
android:orderInCategory="100" app:showAsAction="never" />
<item android:id="@+id/action_search"
android:icon="@drawable/ic_action_search"
android:title="@string/action_search"
app:showAsAction="ifRoom" />
</menu>
<resources>
<string name="app_name">My First App</string>
<string name="action_settings">Settings</string>
<string name="edit_message">Enter a message</string>
<string name="button_send">Send</string>
<string name="title_activity_main">MainActivity</string>
<string name="title_activity_display_message">My Message</string>
<string name="action_search">Search</string>
<string name="hello_world">Hello world!</string>
</resources>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin"
tools:context="com.mycompany.myfirstapp.DisplayMessageActivity">
<TextView android:text="@string/hello_world" android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
package com.mycompany.myfirstapp;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.TextView;
public class DisplayMessageActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Intent intent = getIntent();
String message = intent.getStringExtra(MyActivity.EXTRA_MESSAGE);
TextView textView = new TextView(this);
textView.setTextSize(40);
textView.setText(message);
setContentView(textView);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
//noinspection SimplifiableIfStatement
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
}
这是整个项目.非常感谢你们的帮助.
Here is the entire project. Thank you guys so much for your help.
LogCat文件
05-21 08:49:15.171 181-181/? E/﹕ invalid crash request of size 4 (from pid=16717 uid=0)
05-21 08:49:15.287 541-559/? W/qcom_sensors_hal﹕ hal_sensor1_data_cb: SENSOR1_MSG_TYPE_BROKEN_PIPE
05-21 08:49:15.295 16808-16808/? E/Diag_Lib﹕ Diag_LSM_Init: Failed to open handle to diag driver, error = 2
05-21 08:49:15.295 16808-16808/? E/Sensors﹕ sns_fsa_la.c(386):fsa: fflush failed, 9
05-21 08:49:15.295 16808-16808/? E/Sensors﹕ sns_fsa_la.c(386):fsa: fflush failed, 9
05-21 08:49:15.324 16808-16810/? W/Sensors﹕ sns_smr_la.c(446):smr_la: smr_apps_la_thread_main is starting, fd=11, sns_smr.en_rx_msg_ptr=b70079d0
05-21 08:49:15.383 16808-16812/? W/Sensors﹕ sns_sam_app.c(6827):sns_sam_reg_algo: Registering algo service 16, err 0
05-21 08:49:15.396 16808-16814/? E/Sensors﹕ sns_debug_main.c(565):Debug Config File missing in EFS!
05-21 08:49:21.758 541-3523/? D/WifiService﹕ acquireWifiLockLocked: WifiLock{NlpWifiLock type=2 binder=android.os.BinderProxy@e56ac47}
05-21 08:49:21.778 541-2402/? D/WifiService﹕ releaseWifiLockLocked: WifiLock{NlpWifiLock type=2 binder=android.os.BinderProxy@e56ac47}
推荐答案
<meta-data
android:name="android.support.PARENT_ACTIVITY" />
meta-data
元素始终需要android:value
或android:resource
属性.
完全删除此元素,或向该元素添加一个值,例如:
Either remove this element altogether, or add a value to the element, for example:
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".MyActivity"/>
(PARENT_ACTIVITY
元数据有助于祖先导航.)
这篇关于Android失败[INSTALL_PARSE_FAILED_MANIFEST_MALFORMED]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!