Android Studio Application doesn't start - android-studio

I switched from Eclipse to Android. After a whole time all works. But:
If I'm click on RUN, the app won't start. I test with a real device. If I'm removing the App from the device and click on run, the app will be installed, but that was all. I have to click on it to open it.
I added a Android Application in my Run/Debug Configurations.
What I'm doing wrong?
EDIT:
Here is my Console-Output:
Waiting for device.
Target device: samsung-gt_i9100-000e3cc647f8cf
Uploading file
local path: myApkPath
remote path: remotePath
Installing application
DEVICE SHELL COMMAND: pm install -r "remotePath"

Make sure that in your build configuration, under 'General'->'Activity' you have selected Default Activity.
If you want to run a non-default Activity, it will have to be marked exported=true in AndroidManifest.xml.

Related

Android Studio 3.4 waiting for application to come online

Since upgrading to AS 3.4 I can no longer debug any of my apps. I have made no changes to any of the projects, I just upgraded AS. Now all I get is "Waiting for application to come online".
When I click on Run->Attach Debugger To Android Process, there are no processes to attach.
The apps load and run, but I cannot debug them.
Is there anything I can do to get the debugger working?
(I have tried clean, rebuild, invalidate cache and restart, make project and gradlew clean).
I found the same trobles in Android Studio Dolphin (2021.3.1) when created a new project with no activity. After the project creation I created a main activity and add a launcher intent-filter and tried to debug it. And found "Waiting for application to come online". I found that "Launch" argument in "Lunch Option" for my "Run Configuration" is "Nothing". Problem solved by changing it to "Default Activity"
To change run configuration option select Run->Edit Configurations, or "Modify Run Configuration" in Run or Debug panel.
I had the same problem, I tried: Update Android studio to 3.5, restart cache, delete cache folders, killing adb server and restart it... but nothing works.
I solved executing the next commands on ADB terminal:
On windows, you have to change to platform-tools folder path in order to excecute ADB commands, something like this:
cd C:\Users\YourUser\AppData\Local\Android\Sdk\platform-tools
Then, compile your app on debug mode. (I think shift + F9 on Windows), when you started to see "Waiting for application to come online" message, execute the next adb command:
adb shell am start -n com.example.yourPackage/com.example.yourPackage.MainActivity -D
Just change com.example.yourPackage and make sure MainActivity its your Luncher Activity inside your Manifest File.

Running Program with Emulator, "Local SDK Path not set!"

When I run my program with the emulator on Android Studio I get an error as follows
Local SDK Path Not Set
When i checked this in my project structure my SDK path is
C:\Android\sdk
and this is the same in my SDK Manager. I'm new to Android Studio and am curious of why my emulator loads, but does not run my program.Any help in this regard will be appreciated
In the menu Run > Edit Configurations if you have the deployment target as "Emulator" with no preferred device selected you may run into this issue. Instead, choose deployment target as "Open Select Deployment Target Dialog". This will let you select from any installed emulator or a device connected by USB. Make sure to hit "Apply" before closing the Edit Configurations menu.
Edit Configurations with Emulator but no Emulator
Edit Configurations with Open Select Deployment Target Dialog
I ran in to the same problem after synchronizing gradle. All I had to do was turn the emulator off and on again to fix the problem.
Make sure you are connected to the internet (so Android Studio and Gradle can actually complete their tasks) and perform a Gradle sync ('Sync Project with Gradle Files').
If you still have the error after gradle sync, then set your ANDROID_HOME environment variable.
On macOS, once you know the location of the android SDK, open a terminal window and enter the following:
export ANDROID_HOME={YOUR_PATH}
export PATH=$PATH:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools
source ~/.bash_profile

Android app is not launched in emulator in Android studio

I created an app in Android studio. It builds and runs on my phone but, When i run emulator it runs and shows the phone.
The output:
emulator: WARNING: Crash service did not start
qemu-system-i386.exe: -drive if=none,index=1,id=cache,file=C:\Users\one\.android\avd\Nexus_5_API_23_new.avd/cache.img: could not open disk image C:\Users\one\.android\avd\Nexus_5_API_23_new.avd/cache.img: Could not open 'C:\Users\one\.android\avd\Nexus_5_API_23_new.avd/cache.img': Invalid argument
How to fix this?
It may be bad, but it´s working for me:
First, go to your SDK folder (i.e. %localappdata%\android\sdk)
Open the "tools" folder.
There you find an "emulator-crash-service.exe" file. Copy it to the same folder and rename it to "emulator64-crash-service.exe".
Go back to the SDK Folder and go to the subfolders "extras\intel\Hardware_Accelerated_Execution_Manager\" and launch the "intelhaxm-android.exe" to install the HAXM driver manually.
Now create a new AVD and it should start.
I solved this problem by:
- redownloading Android x86 image (64bits/api23/google_apis in my case)
- creating a new virtual device and choosing Nexus 5 instead of Nexus 4
I'm not sure if all steps are required.

Android Studio can not run or debug app on emulator

I have a very odd situation here:
I just want to run and debug my app on the emulator.
I get
DEVICE SHELL COMMAND: pm install -r "/data/local/tmp/com.example.myapp"
pkg: /data/local/tmp/com.example.myapp
Success
The app is correctly installed on the emulator, but does not start up.
I can run and debug this app on USB-Device.
I can run and debug any other app on same emulator.
I tried different AVDs (arm and intel), SDK and Target
Build finishes with 0 errors and 0 warnings. Eventlog is empty. I cleaned the gradle file and changed the only dependency com.android.support:appcompat-v7:21.+.
I can start the app normally on the AVD by clicking on it's icon.
When I start debugging, app installs, then waits endlessly on:
Waiting for process: com.example.myapp
I do not even now where to start looking (of course I tried rebuilding, synchronizing and cleaning cache). I also tried changing the project name.
Maybe try making a new project and copying your code over?

Sign Application in Android Studio

I am a web developer and I recently decided to learn how to build apps in Android, using the first-party IDE Android Studio.
I spent a few days designing a tutorial app, which I managed to run in an emulator, and then I've been programming and designing the layout for my own app.
However, I've been running into a problem when I try to test the app.
Waiting for device.
Target device: emulator-5556 (Nexus7_2) Uploading file
local path: C:\{file_path}\{app}-release-unsigned.apk
remote path: /data/local/tmp/{app_name}
Installing {app_name}
DEVICE SHELL COMMAND: pm install -r "/data/local/tmp/{app_name}"
pkg: /data/local/tmp/{app_name}
Failure [INSTALL_PARSE_FAILED_NO_CERTIFICATES]
By looking up this error online, I've figured out that I need to sign my app, but I haven't figure out a way for this to work in the case of Android Studio. Modifying the ant build.xml file doesn't work and other methods of signing don't seem to work either.
There is an option to Generate a Signed APK, and I exported an app that was signed. However, I cannot seem to put that apk into my emulator.
If there is anyone more knowledgeable about how to use Android Studio, I would appreciate the assistance in how to sign my apk with the software. Thanks.
Output from Tutorial App
I copied all the code that wasn't included with the new project. This application does work in the emulator.
Waiting for device.
Target device: emulator-5556 (Nexus7_2)
Uploading file
local path: C:\{file_path}\QuoteReader-debug-unaligned.apk
remote path: /data/local/tmp/{app_name}
Installing {app_name}
DEVICE SHELL COMMAND: pm install -r "/data/local/tmp/{app_name}"
pkg: /data/local/tmp/{app_name}
Success
Launching application: ...quotereader.MainActivity.
DEVICE SHELL COMMAND: am start -n "...quotereader.MainActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER
Starting: Intent { act=android.intent.action.MAIN cat= [android.intent.category.LAUNCHER] cmp={app_name}/.MainActivity }
I have found that if you delete the app on your phone then it should work when you run it again.

Resources