Android Studio: Default Activity Not Found and than USB Debugging not woking - android

I re-installed my Android Studio. My first problem was, that when I try to run my Activity, I got an error:
Default Activity Not Found
. So I change the configuration, instead of choosing Default Activity in the Launch Option I choose Nothing.
I think this is the problem why nothing is happening after I run the project. It's make sense, cuz nothing is lauch or am I wrong?
The Android Studio see my device and it's connecting via USB. I done this before, so I know that I have to allow USB Debugging on my device and i did. After I hit run, start to loading, and than it's says that:
Install succesfully finished in 212 ms. App restart succedful without
requiring a re-install.
But nothing is happening neither in my computer or my phone.

In order to start your App, it needs an "entry point". You can define it in the AndroidManifest.xml file like:
<activity android:name="com.myapp.MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
In the first line you add the package path + your Activity you want to open at startup. The reason why you got the error msg Default Activity not found probably is, that you created a project without an Activity.
To create a new Activity simply right-click to the package in Android Studio -> select New -> Activity -> and then e.g. Empty Activity

Just add a filter tag in the Manifest.xml file to the activity that you want the to starts with
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>

Related

installed application from Android Studio opens another activity instead of launcher activity

Whenever I run my app from Android studio, an Activity having
android:exported="true"
get's launched instead of launcher activity
<activity
android:name=".activity.SplashScreen"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|screenSize"
android:label="#string/app_name"
android:screenOrientation="portrait"
android:theme="#style/Theme.AppCompat.NoActionBar"
android:windowSoftInputMode="stateHidden|adjustPan">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
But once app installed, correct launcher activity opens, no issue.
Only issue happens when I launch my app from Android studio(i.e. by running the app). So why this happens?
Without android:exported="true", on some devices, that activity not gets launched after clicking notification of my app. So is it good to keep exported true?
Also I can't post my entire manifest here
When running the app from Android Studio, you're probably using instant run. which applies the code changes to the current running process of your app, so instead of installing the app again, it applies the new changes to the running app, in that case you see the current running activity as it is.
http://android-developers.blogspot.com.eg/2016/04/android-studio-2-0.html
https://developer.android.com/studio/run/index.html
If it only happens in Android Studio and not when the app is installed, it is most likely a problem with the run configuration. You can access it by going to
Run -> Edit Configurations

Cant upload my app with Android Studio

I tried to upload a testing app (just blank page) to my phone.
I can see my phone in the list when I press run and there is no new app in my phone and nothing apears there.
why?
thank you.
Firstly, if you app is failing to compile, you will need to check Android Studio for compilation errors. These can be found in the Messages view.
To put your app on a device, your test device will need USB Debugging enabled on it. Please see this answer for more information on how to turn it on should you have missed this step.
If the app is compiling but isn't starting, ensure that you have the following intent-filter within your main activity's definition in your AndroidManifest.xml file.
<activity
android:name=".YourMainActivityName"
android:label="#string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
This intent filter is how the Android OS works out which activity to launch when the app is freshly opened. Without this filter, no activity will start.

I Can install apk of my project but cant see it, why?

I download my project.apk to my mobile, I install it, at the end it says (Done) and (Open), the (Open) is unhighlighted, I go to (Done). When I look for it to run it, I cant find it, when I go to settings >> Applications to uninstall it, I find it!
Why? :)
In AndroidManifest.xml check if you have this inside the Activity which is your main activity:
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
This is the piece of XML that informs which activity is considered the main activity in your android application. If this information is missing, no launcher will be set, which means no way to start your activity. That's why you don't see an icon of your application, neither can you launch it.

Running Google Glass sample app on Android Virtual Device(emulator)

I am trying to run the Timer sample google glass app, but when I run the project, it gets installed and then says DONE, however, I don't see anything on the emulator. I know there is no Launcher and so I tried the RUN CONFIGURATION but I don't see any activity in the dropdown when I chose the Launch option. Any thoughts or guides on to do this ?
First of all there is no avd/emulator available for Glass.But if still you are interested converting your mobile phone into glass.Check these link i.e 1,2,3.But no one works completely treating your phone as Glass.
As you have mentioned above that you try to install an app on emulator.The main reason why it is not showing up is that:
Move to AndroidManifest.xml
<activity
android:name=".MainActivity"
android:label="#string/app_name" >
This is the normal code for the main launcher activity of android.This is the main activity which is launched in the emulator/avd
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
While in Glass code you find something like this.There is no launcher in Glass but still you can add.Here you only found out the voice trigger which open your app
<intent-filter>
<action android:name="com.google.android.glass.action.VOICE_TRIGGER" />
</intent-filter>
<meta-data
android:name="com.google.android.glass.VoiceTrigger"
android:resource="#xml/voicetrigger" />
</activity>

Eclipse Android launcher shows home screen, not my application

When I launch my android application from eclipse, it shows the home screen, and I then need to unlock the screen and go to my app. I would like it to just show my app by default.
I have tried right clicking on the app and selecting Run As..., but Android Application is not a choice there. I need to manually create a new Android run configuration for my application and then I launch that.
Is there a way to just make my app show by default? I'm running with the emulator for Android version 2.2?
Note: I'm also getting an error that says "Emulator] Unknown savevm section type 95" which I'm not sure what that means yet
thanks,
Jeff
The emulator always starts with the screen locked. Unlock it and wait a moment, sometimes it needs a minute to launch your app. If it doesn't work after a few moments, leave the emulator open and try running it again. If it doesn't launch now, there's something wrong.
I'm thinking you either didn't create your project as an android project to begin with, or if you did you didn't create a starting activity (or deleted the one that you did create)? Either way, you probably need to go edit your AndroidManifest.xml file and add an intent filter to an activity. Just guessing. Should look similar to this:
<activity
android:name={String for the name of your app}
android:label={String for the name displayed on the icon}>
<intent-filter>
<action
android:name="android.intent.action.MAIN"/>
<category
android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
** posted before your edit ^^^
In terms of your error, I have no clue what that is, so maybe it has nothing to do with your AndroidManifest, then. :T
Check your manifest, and make sure your activity has the correct intent-filter
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
BTW, Previous to Android 1.6 i think the emulator always started with the screen locked then they changed that and it starts with your app

Categories

Resources