Android 错误“应用程序未安装”
我正在使用 Droid X 来测试我的应用程序,它工作正常,直到我向应用程序添加了多个活动,错误显示“应用程序未安装”。我添加了一些使用WebView的活动,代码如下。我注意到,每当我删除这些活动或仅删除其中一些活动时,应用程序就会重新开始工作。我在清单中添加了以下权限。已经两天了,我还是找不到答案。我真的需要你的帮助。我真的猜测问题来自太多的活动,但是我该如何处理它,我在清单中添加了所需的所有内容,但仍然一遍又一遍地出现相同的错误。
这是我的manifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.test.cats"
android:versionCode="1"
android:versionName="1.0">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"></uses-permission>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"></uses-permission>
<uses-sdk android:minSdkVersion="8" />
<application android:icon="@drawable/icon" android:label="@string/app_name">
<activity android:name=".MainActivity"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
android:screenOrientation="portrait"
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=".Activity1"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
android:screenOrientation="landscape"/>
<activity android:name=".Activity2"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
android:screenOrientation="landscape"/>
<activity android:name=".Activity3"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
android:screenOrientation="landscape"/>
<activity android:name=".Activity4"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
android:screenOrientation="landscape"/>
<activity android:name=".Activity5"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
android:screenOrientation="landscape"/>
<activity android:name=".Activity6"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
android:screenOrientation="landscape"/>
<activity android:name=".Activity7"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
android:screenOrientation="landscape"/>
<activity android:name=".Activity8"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
android:screenOrientation="landscape"/>
<activity android:name=".Activity9"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
android:screenOrientation="landscape"/>
<activity android:name=".Activity10"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
android:screenOrientation="landscape"/>
<activity android:name=".Activity11"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
android:screenOrientation="landscape"/>
<activity android:name=".Activity12"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
android:screenOrientation="landscape"/>
<activity android:name=".Activity13"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
android:screenOrientation="landscape"/>
<activity android:name=".Activity14"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
android:screenOrientation="landscape"/>
<activity android:name=".Activity15"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
android:screenOrientation="landscape"/>
<activity android:name=".Activity16"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
android:screenOrientation="landscape"/>
<activity android:name=".Activity17"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
android:screenOrientation="landscape"/>
<activity android:name=".Activity18"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
android:screenOrientation="landscape"/>
<activity android:name=".Activity19"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
android:screenOrientation="landscape"/>
<activity android:name=".Activity20"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
android:screenOrientation="landscape"/>
</application>
</manifest>
- 这是我的活动:
package com.test.cats;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.webkit.WebView;
public class Activity3 extends Activity {
WebView webView;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.webviewlayout);
webView = (WebView) findViewById(R.id.webview);
webView.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);
webView.getSettings().setJavaScriptEnabled(true);
webView.getSettings().setAllowFileAccess(true);
webView.getSettings().setPluginsEnabled(true);
webView.loadUrl("http://www.mywebsite.com/video.html");
}
@Override
protected void onPause(){
super.onPause();
callHiddenWebViewMethod("onPause");
webView.pauseTimers();
if(isFinishing()){
webView.loadUrl("about:blank");
}
}
@Override
protected void onResume(){
super.onResume();
callHiddenWebViewMethod("onResume");
webView.resumeTimers();
}
private void callHiddenWebViewMethod(String name){
if( webView != null ){
try {
Method method = WebView.class.getMethod(name);
method.invoke(webView);
} catch (NoSuchMethodException e) {
//Lo.g("No such method: " + name + e);
} catch (IllegalAccessException e) {
//Lo.g("Illegal Access: " + name + e);
} catch (InvocationTargetException e) {
//Lo.g("Invocation Target Exception: " + name + e);
}
}
}
public void onBackPressed(){
Activity2.this.finish();
return;
}
}
I am using Droid X to test my application and it was working fine until I added several Activities to my application, the error says "Application not installed". I added few Activities that uses WebView, the code is below. I noticed that whenever I removed these Activities or remove just SOME of them, the app starts working again. I have added the following permissions below in my Manifest. It has been two days, and I can't still find the answer. I really need your help. I'm really guessing that the problems comes from too much Activities, but how can I handle it, I added everything that are need in my Manifest and still getting the same error over and over.
Here is my manifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.test.cats"
android:versionCode="1"
android:versionName="1.0">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"></uses-permission>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"></uses-permission>
<uses-sdk android:minSdkVersion="8" />
<application android:icon="@drawable/icon" android:label="@string/app_name">
<activity android:name=".MainActivity"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
android:screenOrientation="portrait"
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=".Activity1"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
android:screenOrientation="landscape"/>
<activity android:name=".Activity2"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
android:screenOrientation="landscape"/>
<activity android:name=".Activity3"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
android:screenOrientation="landscape"/>
<activity android:name=".Activity4"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
android:screenOrientation="landscape"/>
<activity android:name=".Activity5"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
android:screenOrientation="landscape"/>
<activity android:name=".Activity6"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
android:screenOrientation="landscape"/>
<activity android:name=".Activity7"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
android:screenOrientation="landscape"/>
<activity android:name=".Activity8"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
android:screenOrientation="landscape"/>
<activity android:name=".Activity9"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
android:screenOrientation="landscape"/>
<activity android:name=".Activity10"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
android:screenOrientation="landscape"/>
<activity android:name=".Activity11"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
android:screenOrientation="landscape"/>
<activity android:name=".Activity12"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
android:screenOrientation="landscape"/>
<activity android:name=".Activity13"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
android:screenOrientation="landscape"/>
<activity android:name=".Activity14"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
android:screenOrientation="landscape"/>
<activity android:name=".Activity15"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
android:screenOrientation="landscape"/>
<activity android:name=".Activity16"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
android:screenOrientation="landscape"/>
<activity android:name=".Activity17"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
android:screenOrientation="landscape"/>
<activity android:name=".Activity18"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
android:screenOrientation="landscape"/>
<activity android:name=".Activity19"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
android:screenOrientation="landscape"/>
<activity android:name=".Activity20"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
android:screenOrientation="landscape"/>
</application>
</manifest>
-
Here is my activity:
package com.test.cats;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.webkit.WebView;
public class Activity3 extends Activity {
WebView webView;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.webviewlayout);
webView = (WebView) findViewById(R.id.webview);
webView.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);
webView.getSettings().setJavaScriptEnabled(true);
webView.getSettings().setAllowFileAccess(true);
webView.getSettings().setPluginsEnabled(true);
webView.loadUrl("http://www.mywebsite.com/video.html");
}
@Override
protected void onPause(){
super.onPause();
callHiddenWebViewMethod("onPause");
webView.pauseTimers();
if(isFinishing()){
webView.loadUrl("about:blank");
}
}
@Override
protected void onResume(){
super.onResume();
callHiddenWebViewMethod("onResume");
webView.resumeTimers();
}
private void callHiddenWebViewMethod(String name){
if( webView != null ){
try {
Method method = WebView.class.getMethod(name);
method.invoke(webView);
} catch (NoSuchMethodException e) {
//Lo.g("No such method: " + name + e);
} catch (IllegalAccessException e) {
//Lo.g("Illegal Access: " + name + e);
} catch (InvocationTargetException e) {
//Lo.g("Invocation Target Exception: " + name + e);
}
}
}
public void onBackPressed(){
Activity2.this.finish();
return;
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
当您在清单文件中多次声明某个活动时,就会发生这种情况。删除
android:label="@string/app_name">
并重试。您已声明两次。可能这就是它不起作用的原因This occurs when you have declared an activity more than once in your manifest file. Remove
android:label="@string/app_name">
and try again. You have declared this twice. May be this is the reason its not working我想问题可能出在这里:
尽管您使用 Activity3,但您尝试调用 Activity2 的 finish 方法。
I guess the problem can be here:
You try to call finish method for Activity2 although you work with Activity3.