I am working on a demo project for my Pluralsight training course, and am trying to do something as simple as adding a new activity through Android Studio UI. I right-click on the main folder under "Java" folder (normal android folder structure) and choose 'activity'...'navigation drawer activity'. I go through all the wizard steps, and the new entry gets made in the AndroidManifest.xml file. Yet, the UI resource xml file doesn't get created and kotlin .kt file doesn't get created, either. I have a Windows 10 machine and a Kubuntu 20.04 machine and have gotten this same behavior on both.
Here are the Android studio build details from my Kubuntu machine, which I use the most:
Android Studio 4.0.1
Build #AI-193.6911.18.40.6626763, built on June 24, 2020
Runtime version: 1.8.0_242-release-1644-b3-6222593 amd64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Linux 5.4.0-42-generic
GC: ParNew, ConcurrentMarkSweep
Memory: 2014M
Cores: 4
Registry: ide.new.welcome.screen.force=true
Non-Bundled Plugins:
This is the AndroidManifest.xml file. the activity I am trying to add is called .ItemActivity. The IDE is underlining it in red, saying that I don't have the accompanying class file and the resource file in the project, but I already know that.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.notekeeper" >
<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=".ItemsActivity"
android:label="#string/title_activity_items"
android:theme="#style/AppTheme.NoActionBar" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".NoteListActivity"
android:label="#string/app_name"
android:theme="#style/AppTheme.NoActionBar" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".NoteActivity"
android:label="#string/note_edit"
android:theme="#style/AppTheme.NoActionBar" />
</application>
</manifest>
Related
I have been following a YouTube tutorial on 2D Game development and when I pressed the run button to check, it shows:
Error runing "app": Default Activity not found
Also it shows an error on AndroidMainfest.xml if I use landscape instead of fullsensor:
<activity android:name=".GameActivity"
android:screenOrientation="landscape"
android:theme="#style/AppTheme.noActionBar"></activity>
<activity
android:name=".MainActivity"
android:screenOrientation="landscape"
android:theme="#style/AppTheme.noActionBar"></activity>
Use intent-filter:
<activity
android:name=".MainActivity"
android:screenOrientation="landscape"
android:theme="#style/AppTheme.NoActionBar"
>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
And why #style/AppTheme.noActionBar? Use #style/AppTheme.NoActionBar.
See also "Default Activity Not Found" on Android Studio upgrade.
I have an app I was working on a few months ago. Today I opened it again in Android Studio 3.4 and when syncing it asked if OK to upgrade to the current version of Gradle and the Gradle plug-in. I agreed and I now get an XML parsing error in the manifest.
The manifest is here, I added a comment to signal where I get the error:
<?xml version="1.0" encoding="utf-8"?>
<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
package="com.schalkx.alarmapp01">
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.VIBRATE" />
<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/Theme.AppCompat">
<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=".SetAlarmActivity">
android:label="Alarm Settings"
android:parentActivityName=".MainActivity" <!-- *** I GET THE ERROR HERE *** -->
<!-- Parent activity meta-data to support 4.0 and lower -->
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".MainActivity" />
</activity>
<activity android:name=".ShowClockActivity">
android:label="Desktop Clock"</activity>
<receiver android:name=".AlarmReceiver" />
<activity
android:name=".UserResponseActivity"
android:label="#string/title_activity_user_response" />
<meta-data
android:name="preloaded_fonts"
android:resource="#array/preloaded_fonts" />
</application>
</manifest>
I did some tests adding a new activity and I noticed that the syntax is now generated a bit differently, and would start like this:
<activity
android:name=".SetAlarmActivity"
android:label="Alarm Settings"
android:parentActivityName=".MainActivity"
....
That is, the ">" is not added at the end of
<activity android:name=".SetAlarmActivity">
but later on. Trouble is I haven't been able to get the syntax right.
Any ideas what's wrong?
Thanks!
It should be
<activity android:name=".SetAlarmActivity"
android:label="Alarm Settings"
android:parentActivityName=".MainActivity"> //<--Notice
Instead of
<activity android:name=".SetAlarmActivity"> //<--Notice
android:label="Alarm Settings"
android:parentActivityName=".MainActivity"
I'm currently Android Studio 2.3.3 and S6 Edge to test my app on the real device but it keep giving me an error saying Error running app: Default Activity Not Found.
I have
<activity
android:name=".MainActivity"
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" />
</intent-filter>
</activity>
and tried restart Androdi Studio but error is still there.
Does anyone know how to figure this out?
Thank you
Put your MainActivity Theme inside MainActivity.
Something like:
android:theme="#style/AppTheme.NoActionBar"
Make sure it's inside the application node.
Like this:
<application
android:name="YOUR_APP_NAMESPACE_HERE"
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"
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" />
</intent-filter>
</activity>
</application>
1st Step
Select 'app', then 'edit configurations'.
enter image description here
Select "nothing" in launch.
When I execute the following command
adb shell am startservice vision.fastfiletransfer/com.android.tools.fd.runtime.InstantRunService
it has the error
Error while executing: am startservice vision.fastfiletransfer/com.android.tools.fd.runtime.InstantRunService
Starting service: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=vision.fastfiletransfer/com.android.tools.fd.runtime.InstantRunService }
Error: Requires permission private to package
And I use AndroidStudio 2.3 to debug,what is wrong? What is more,my AndroidManifest is like this.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="vision.fastfiletransfer" >
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme"
android:name="base.APP">
<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>
<activity
android:name=".ShareActivity"
android:label="#string/title_activity_share" >
</activity>
</application>
</manifest>
I had the same problem and I found two solutions that worked for me.
Solution 1. This doesn't need to change your SDK. You have to go File > Settings > Build, Execution, Deployment > Instant Run and uncheck the first checkbox to disable Instant Run.
Solution 2. The emulator device has to give autolunch permission to the app. In most of devices and older SDK platforms, it is already set. But in my case (Nexus 5s, android-25), this permission doesn't exist anymore.
I had to choose an older device (older API) and it worked.
I had the same question in my project since upadted Android studio to 2.3 ,it seems that there is a studio's bug. You can try to use 2.2.3 .
I get these errors while building a signed apk using Android Studio. Help me build the app please.
1.
Error:(42, 28) No resource found that matches the given name (at
'value' with value '#integer/google_play_services_version').
2.
Error:Execution failed for task ':app:processDebugResources'.
com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command
'/home/dna/Android/Sdk/build-tools/23.0.2/aapt'' finished with
non-zero exit value 1
This is my AndroidManifest.xml file
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="appen.woltlab_bb"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="15"
android:targetSdkVersion="23" />
<uses-permission android:name="android.permission.INTERNET" />
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="appen.woltlab_bb.SplashScreen"
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="appen.woltlab_bb.MainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="appen.woltlab_bb.MAINACTIVITY" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<!--
ATTENTION: This was auto-generated to add Google Play services to your project for
App Indexing. See https://g.co/AppIndexing/AndroidStudio for more information.
-->
<meta-data
android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
</application>
</manifest>
I got it fixed. It was caused due to having accidentally including some auto generated API indexing code from a similar project by me. In case you have this issue, just start from scratch and be careful with what you import from your previous project.