I am a new android programmer.
I created a simple "Hello World" app in android studio, but when I run it on an AVD, it gives the following error:
Unexpected error while executing: am start -n "com.example.ahrims.helloworld/com.example.ahrims.helloworld.MainActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER
Error while Launching activity
EDIT 1:
Here is the manifest file:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.ahrims.helloworld">
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity android:name=".MainActivity"
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>
</manifest>
Edit 2:
The following is MainActivity file:
package com.example.ahrims.helloworld;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
public class MainActivity extends AppCompatActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
}
I googled it, but did not find any useful answer.
Any help would be appreciated.
Thanks in advance.
Remove the .idea folder and gradle folder, then click "sync project with gradle" gradle files, after this process finished, you are able to run your app
Related
I try to resolve this error from various methods in my Hello World App.These are;
-Go to Security-->Unknown sources.
-Go to About phone-->Build number.
-Update my manifest file whose picture is given below.
-Test app both on phone Y625 Huawei and on tablet T1-701u tab.
-Reboot android phone and android studio (version 3.4.1).
-Transfer apk file via data cable or airmove software.
But none of them works to solve the issue.
I develop my Hello World. Firstly i faced insufficient heap size error issue which has solved on the temporary basis. After build up my app, Parsing the package issue has emerged.
Manifest File:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.hw04">
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
MainActivity.java
package com.example.hw04;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
public class MainActivity extends AppCompatActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
}
Parse Error
There was a problem parsing the package enter code here
Error while executing: am start -n
"com.example.myapplication/com.example.myapplication.Detail" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER
Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.example.myapplication/.Detail }
Error type 3
Error: Activity class {com.example.myapplication/com.example.myapplication.Detail} does not exist.
Error while Launching activity
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.myapplication">
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter >
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".Detail"
android:label="SQLite Example - Details"></activity>
</application>
</manifest>
It is a easy problem which is happened when you migrate to androidX (at least it happened for me by this reason).
An easy solution is:
making a new project (same package name as the current one)
go to app\src\main and delete all files in main directory (for this new project)
go to app\src\main and copy all files in main directory (for the old project)
past the files in app\src\main directory (the new project)
run the new project
So I'm getting the MainActivity does not exist error, it might be because I renamed the package and app from bomber to Bomber and changed the appId from com.bomber to cool.bomber.android
I've checked the AndroidManifest, the activity source files and the build.gradle file but I can't seem to find what's the mistake
Error message
Starting: Intent { cmp=cool.bomber.android/.MainActivity }
Error type 3
Error: Activity class {cool.bomber.android/cool.bomber.android.MainActivity} does not exist.
app/build.gradle
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "cool.bomber.android"
...
AndroidMaifest.xml
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
<uses-permission android:name="android.permission.CAMERA" />
<uses-sdk
android:minSdkVersion="16"
android:targetSdkVersion="22" />
<application
android:name=".MainApplication"
android:allowBackup="true"
android:label="#string/app_name"
android:icon="#mipmap/ic_launcher"
android:theme="#style/AppTheme">
<activity
android:name=".MainActivity"
android:launchMode="singleTask"
android:label="#string/app_name"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
android:windowSoftInputMode="adjustResize">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
<category android:name="com.google.intent.category.CARDBOARD" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE"/>
<data android:host="foo.app.goo.gl" android:scheme="http"/>
<data android:host="foo.app.goo.gl" android:scheme="https"/>
</intent-filter>
</activity>
<activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
</application>
android/app/src/main/java/cool/bomber/android/MainActivity.java
package cool.bomber.android;
import com.facebook.react.ReactActivity;
public class MainActivity extends ReactActivity {
#Override
protected String getMainComponentName() {
return "Bomber";
}
}
I'm not sure what else I should be looking at to debug.
You need to uninstall the application properly.
If it does not work from the phone, you can use cmd
adb uninstall "package name"
Add package name in manifest:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="cool.bomber.android">
and still not working than write full package name like this
<application
android:name="cool.bomber.android.MainApplication"
android:allowBackup="true" >
<activity
android:name="cool.bomber.android.MainActivity"
>
and make sure this is the right path
and in CMD write this:
cd android & gradlew clean
or maybe
cd android && ./gradlew clean
and than run react-native run-android
Make sure when you write this code you are at root of your project folder
Or Else:
Follow this to refresh whole project after changing package using android studio.
For me the problem was that I had added tools:node="replace" to my android/app/src/debug/AndroidManifest.xml:
<application android:usesCleartextTraffic="true" tools:targetApi="28" tools:ignore="GoogleAppIndexingWarning" tools:node="replace"/>
I had added that based on someone recommending it for some other issue and it caused the infamous Error type 3 to appear. Once I got rid of it, the problem went away:
<application android:usesCleartextTraffic="true" tools:targetApi="28" tools:ignore="GoogleAppIndexingWarning"/>
Cheers,
Alvaro
I had to reinstall the app for the problem to be resolved
I have two Android projects. One is a library and compiles a jar the other an executable which includes this jar on the build path.
I'm subclassing an activity in the jar in my project but when I start it I'm getting a ClassNotFoundException.
Here's the manifest with the activity in question being MainActivity:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.my.package.MyProject"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk android:minSdkVersion="8" />
<application android:label="#string/app_name"
android:name=".MyApplication"
android:icon="#drawable/ic_launcher"
android:theme="#style/AppTheme">
<activity android:label="#string/app_name"
android:configChanges="orientation|keyboardHidden"
android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
And here is my MainActivity, where the QCARSamples package is found in my jar:
package com.my.package.MyProject;
import java.io.File;
import com.qualcomm.QCARSamples.ImageTargets.GraphicsEngineHook;
import com.qualcomm.QCARSamples.ImageTargets.VuforiaTrackingActivity;
import com.my.package.MyProject.R;
public class MainActivity extends VuforiaTrackingActivity{
private File blenderFile;
#Override
protected synchronized void updateApplicationStatus(final int appStatus){
return;
}
#Override
protected GraphicsEngineHook getGraphicsEngineHook() {
return new MyGraphicsEngineHook();
}
#Override
protected int getSplashScreenImageResource() {
return R.drawable.splash_screen_image_targets;
}
}
I also tried including the activity I'm subclassing in my manifest like so, but I was still getting the same error:
<activity>
<android:name="com.qualcomm.QCARSamples.ImageTargets.VuforiaTrackingActivity>
</activity>
Any ideas?
The problem is usually on the BuildPath.
Assuming you're using eclipse and ADT:
Right click on your project, select Build Path -> Configure Build Path -> Order and Export and make sure that your library is selected.
Remember to clean the project before trying again.
it could also be the class path as the guy suggested on the commented, on the manifest, instead of editing direct the XML, go to the Application tab, select the activity, click Browser, uncheck 'Display classes from sources of Project ...', and select the Activity from your library.
EDIT: SOLVED I JUST HAD TO WAIT FOR AWHILE
So I followed the simple "Hello Android" tutorial:
http://developer.android.com/resources/tutorials/hello-world.html
got everything set up fine.....stuff works but when I go to actually run it.....it just says "Android_" in my virtual device....
I tried running it on 2.1 2.2 2.3.1 and 2.3.3 VD's and get the same thing?
package com.example.helloandroid;
import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;
public class HelloAndroid extends Activity {
/** Called when the activity is first created. */
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
TextView tv = new TextView(this);
tv.setText("Hello, Android");
setContentView(tv);
}
}
Any ideas? My first venture into android is a failing one ;_;
PIC:
bigger:http://img.photobucket.com/albums/v720/bmw_pyro/Untitled-2.png
MANIFEST:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.helloandroid"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk android:minSdkVersion="10" />
<application android:icon="#drawable/icon" android:label="#string/app_name">
<activity android:name=".HelloAndroid"
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>
</manifest>
"Android _" is the first loading emulator splash screen, so you are saying that you get stuck there? If that's the case, that has nothing to do with your code.