Android Studio 4.0 file > New > Activity OR Fragment not working - android-studio

I have android studio 4.0 installed & I am unable to create new activity OR fragment from File > New menu.
All that happens is just a gradle build & files don't show up after I click the Finish button.
Following is the system environment.
Studio Version: 4.0
SDK build tool: 30
Gradle wrapper: 6.1.1
OS: macOS Catalina (10.15.2)
Machine: MacBook Air (2017
I am using an android navigation UI version: 2.2.2 and also tried to create new activity/fragment from navigation file using New Destination still no result.
Let me know if any other information is required.

Please open your app build.gradle file and delete debug config from signingConfigs and try again:
signingConfigs {
// delete this entire debug block
debug {
storeFile file('file path')
storePassword 'password'
keyPassword 'password'
keyAlias = 'password'
}
}

My solution and I think it might also comes rescue you.You have to update the minSdk version to the required version. You probably the min version required while trying to create the activity.
Follow the step below:
step-1:File--->Project structure
File--->Project structure
step-2: Modules--->Default config
Modules--->Default config
Now set your minSdk to the required value and hit the apply followed by ok.
Hopefully you will get the activity windows now.

This is how I solved it for version 4.1.2:
on the top menu of android studio click on Build --> Clean Project, after that Build --> Rebuild.
It will tell you the error causing trouble, for me it was that android studio did not properly close the manifest tag in the manifest file. Once I closed the tag and rebuilt the project again, everything worked fine.

Related

Playstore error: App Bundle contains native code, and you've not uploaded debug symbols

When I want to release a new flutter app bundle to the Playstore. I get this error:
"This App Bundle contains native code, and you've not uploaded debug symbols. We recommend you upload a symbol file to make your crashes and ANRs easier to analyze and debug."
I can't find any way to fix this. I'm new with flutter and releasing app's and getting a bit desperate...
Any help would be fantastic.
When I add "android.defaultConfig.ndk.debugSymbolLevel = 'FULL'" (on line 1) to the app/build.gradle as suggested in https://developer.android.com/studio/preview/features#native-crash-symbolization. I get This error in the Android studio terminal. I use this command "flutter build appbundle".
Error in Terminal:
FAILURE: Build failed with an exception.
Where:
Build file 'C:\Users\filip\AndroidStudioProjects\ehbo\android\app\build.gradle' line: 1
What went wrong:
A problem occurred evaluating project ':app'.
Could not get unknown property 'android' for project ':app' of type org.gradle.api.Project.
Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
Get more help at https://help.gradle.org
BUILD FAILED in 3s
Running Gradle task 'bundleRelease'...
Running Gradle task 'bundleRelease'... Done 4,3s
Gradle task bundleRelease failed with exit code 1
Reproduce next steps and this warning will disapear
Go to
[YOUR_PROJECT]\build\app\intermediates\merged_native_libs\release\out\lib
note that 3 folders exist inside
arm64-v8a
armeabi-v7a
x86_64
Select this 3 folder and create a .zip file. Name doesn't matter.
[PLEASE NOTE THAT I HAVEN'T COMPRESSED THE ./lib FOLDER]
Upload this new *.zip file as Symbol File.
.
If talking about Flutter, looks like the Flutter team needs to change some source files for the NDK, because it does not see where from to generate debug symbols.
Here is an issue thread: https://github.com/flutter/flutter/issues/60240
Setup steps are so:
Pre-condition: Intall Android studio 4.1+ and Gradle 4.1+
Install NDK (Side by Side) in SDK manager
Write path to NDK in local.properties
Add in app/build.gradle (last line) android.buildTypes.release.ndk.debugSymbolLevel = 'FULL'
Before you can upload debug symbols files, you must be using Android Gradle plugin version 4.1 or higher.
Looks like it will come only with Android Studio 4.1, because I can only get Gradle 4.0.0 automatically now.
So I suggest you to return classic Play console and it will let you through :)
UPDATE:
So just use an updated Gradle and add NDK debug symbols to the build now
The Answer was given by Shakle will be not useful as per the following message on Play Console.
The old version of Play Console will be discontinued from November 2,
2020 You’re already using the new Play Console, so you don’t need to
do anything. A few features are going away if you want to check them
one last time.
It's just a warning, nothing else. Just go ahead.
If you don't want any warning, Go to this link and follow the steps:
https://support.google.com/googleplay/android-developer/answer/9848633?hl=en
You can use the new version of the play store as it is.
you can make these zip file by go to build\app\intermediates\merged_native_libs\release\out\lib inside your Flutter project
and compress the folders into symbols.zip, now upload it into the google play console
I had a similar problem.
What really helped me:
Make sure your Android Gradle plugin version is 4.1 or later.
Install NDK (Side by Side) in SDK manager.
Install CMake in SDK manager.
Add
ndkVersion <ndkVersion>
ndk {
debugSymbolLevel 'FULL'
}
to app/build.gradle
My final build.gradle:
...
android {
compileSdkVersion 30
defaultConfig {
applicationId "com.example.app"
minSdkVersion 21
targetSdkVersion 30
versionCode 28
versionName "1.0.59"
ndkVersion "23.1.7779620"
ndk {
debugSymbolLevel 'FULL'
}
}
buildTypes {
release {
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
configurations {
compile.exclude group: 'com.google.zxing'
}
}
...
I hope this will help you and save you time
If you want to solve this warning error:
This App Bundle contains native code, and you've not uploaded debug symbols. We recommend you upload a symbol file to make your crashes and ANRs easier to analyze and debug. Make sure also to install CMake
This will happen if your gradle version is higher than 4.0
Place this code into your build.gradle file
android {
compileSdkVersion 28
defaultConfig {
applicationId 'com.example.myproject'
minSdkVersion 21
targetSdkVersion 28
versionCode 1
versionName "1.0.0"
ndk {
debugSymbolLevel 'FULL'
}
}
Instead of creating and uploading zip files, you can include the following to your app\build.gradle file:
buildTypes {
debug {
// This is just here for local testing and is optional.
firebaseCrashlytics {
nativeSymbolUploadEnabled true
unstrippedNativeLibsDir file("build/app/intermediates/merged_native_libs/debug/out/lib")
}
ndk {
debugSymbolLevel 'SYMBOL_TABLE'
}
}
release {
// ..
firebaseCrashlytics { // Insert this
nativeSymbolUploadEnabled true
unstrippedNativeLibsDir file("build/app/intermediates/merged_native_libs/release/out/lib")
}
ndk {
// replace with 'FULL' if you need more info,
// but note that it will increase the file size of your appbundle dramatically.
debugSymbolLevel 'SYMBOL_TABLE'
}
}
}
Here is some documentation for reference:
https://firebase.google.com/docs/crashlytics/ndk-reports#upload-symbols-external-dependencies
And if you're unclear about how to set up automatic uploading of native symbols, try adding this:
buildTypes { ... } // Your build types from the above snippet.
tasks.whenTaskAdded { task ->
if (task.name.startsWith('assemble') && task.name != "assembleReleaseAndroidTest"
&& task.name != "assembleDebugAndroidTest") {
String taskName = "uploadCrashlyticsSymbolFile" + task.name.substring('assemble'.length())
task.finalizedBy taskName
doFirst {
println "Running Gradle task '$taskName'..."
}
}
}
More info for building gradle tasks here:
https://docs.gradle.org/current/userguide/tutorial_using_tasks.html
Also, ensure that you have NDK and CMAKE installed in your IDE's SDK Manager.
Hope that helps!
Simple approach, go to \build\app\intermediates\merged_native_libs\release\out\lib , you will find 3/4 folders , zip those , upload this ZIP from release option ( upload Symbol File ). Warning will be gone after bundle review.
For fixing it in the Visual Studio Code: you should first download
the NDK from the android's website.
Extract the zip file to a folder named ndk and place it under your - already installed - Android SDK folder. Like this: Android/sdk/ndk
Then open app/build.gradle.
Under the Android section. Add ndkPath property as follows: ndkPath = <ndk-dir>
app/build.gradle ndkPath property
At the end of app/build.gradle add android.buildTypes.release.ndk.debugSymbolLevel = 'full'
The next appbundle, built by flutter build appbundle command should not give any errors on the play store about native debug symbols.
a more thorough explanation is here
I just upgraded ndk from 21.4.7075529 to 22.1.7171670, and now I get the debug symbols.
I'm using com.android.tools.build:gradle:7.1.1 and React Natvive 0.69 BTW.
I have the exact same issue.
Possible solutions:
Use the Google classic Play console
Gradle 4.1 is now released with Android Studio 4.1
Could not get unknown property 'android' for project ':app' of type org.gradle.api.Project.
You have to add it in gradle.properties not build.gradle
I was able to get Flutter to build native debug symbols using Android Gradle Plugin (AGP) 4.1.0, installing corresponding NDK version and adding the appropriate config to android/app/build.gradle on macOS (but it should also work on Windows/Linux).
Optional: Run flutter build appbundle and take note of the .aab file size
Check what version of AGP you're using in android/build.gradle by looking in dependencies e.g. com.android.tools.build:gradle:4.1.0 is 4.1.0
Check which version of NDK you need. Assuming your AGP is 4.1.0 the NDK version you want to install is 21.1.6352462 (for other AGP versions check mappings here)
Install specific NDK version using Android Studio. Alternatively you can use sdkmanager and the CLI: $ANDROID_HOME/tools/bin/sdkmanager --install "ndk;21.1.6352462"
In android/app/build.gradle, under android.defaultConfig add ndk { debugSymbolLevel 'FULL' } aka set android.defaultConfig.ndk.debugSymbolLevel = 'FULL' as per this
Run flutter build appbundle. The .aab should now contain native debug symbols and be larger than the previous build in step 0
Troubleshooting: If you get any errors around CMake I didn't explicitly install it but you might need to, especially if you're using Windows, and you can do so using Android Studio.
screenshot
My issue was this:
This App Bundle contains native code, and you've not uploaded debug symbols. We recommend you upload a symbol file to make your crashes and ANRs easier to analyze and debug.
Fix successfully just upload native debug symbols from the image reference directory shown.

Can't configure SDK after installation of Android Studio

So I got my new laptop(Win 10) and installed the Android studio 2.2.3 with SDK bundle.
When I first executed Android Studio it got stuck on the splash screen. adding "Add disable.android.first.run=true" to the idea.properties file solved it.
After I got to the first screen, I needed to configure SDK in order to create new project so I clicked on Configure->Project Defaults -> project structure.
I set the location of the SDK and JDK , and then it gets stuck with the "Checking Availability" message:
Checking Availability
I also tried to configure the sdk by clicking from the first screen on
Configure -> SDK Manager.
In this screen it also gets stuck with the message :Looking for updates":
Looking for updates
I tried to install it as Administrator and also to install lower version.
It didn't help.
Thanks in advance
First of all update Android Studio to latest version(V2.3.1) with complete bundle.
Then you don't need to install jdk manually. after finish installation check "Use embedded jdk" in project structure if not checked. and if you needed Android NDK kit then you can download it later.

Kotlin app build failed due to "Could not initialize class com.intellij.ide.highlighter.JavaFileType"

I've just updated Android Studio to 2.2 and now my Kotlin project won't build. The gradle synch works fine, but when attempting to build I'm immediately presented with an error that reads:
Error:Execution failed for task ':app:compileDebugKotlin'.
> Could not initialize class com.intellij.ide.highlighter.JavaFileType
I've checked that my Kotlin plugin is up to date. This error sounds like something to do with the IDE and highlighting Java code? Any help would be appreciated.
Open Tools | Kotlin | Configure Kotlin Plugin Updates in the main menu,
then choose Check for Updates. Be sure that yo're using Stable channel.
Close Android Studio, go to your project's directory, and delete build and app/build folders. Run Android Studio. Deleted folders would be recreated.
Hope it will help
In my case the kotlin plugin was not updated as #piotrek1543 said in other answer.
In addition to that the build.gradle had an old Kotlin version number 1.0.1-2 and the IntelliJ said in a warning on top of to switch to the current bundled version 1.0.4.
Now with the kotlin version like this the error is gone:
ext.kotlin_version = '1.0.4'

Getting error while importing my old project to Android studio 2.0

I just download the latest Android studio and trying to import my old project which was good with the last version. But I am getting
Error:org.gradle.tooling.BuildActionExecuter.withCancellationToken(Lorg/gradle/tooling/CancellationToken;)Lorg/gradle/tooling/BuildActionExecuter;
I am also getting this error when I am creating new projects.
Any suggestion to solve this problem?
Method : 1.
1.Close Android Studio
2.go to android-studio/plugins/gradle/lib
3.Delete (or better move them somewhere to have a backup) all
gradle-*-1.8 files
Start Android Studio again and rebuild/refresh.
It should work
Method : 2.
Choose another path of gradle in:
File --> settings --> Build,Execution --> Build Tools --> Gradle
If you use of ver 2 select path of installed android studio and select gradle Folder.
I just deleted all the file from my install directory and re-extracted the file, the problem gone.

Android Studio - Gradle sync error on gradle-diagnostics-X.X.X.jar

I've just updated Android Studio and I can't sync my project anymore.
The event log reports:
Gradle sync failed: /Applications/Android Studio.app/Contents/gradle/gradle-X.X.X/lib/plugins/gradle-diagnostics-X.X.X.jar (No such file or directory)
To solve the Gradle sync error, open gradle-wrapper.properties file and update the Gradle wrapper distribution version from:
distributionUrl=https\://services.gradle.org/distributions/gradle-X.X.X-all.zip
To:
Android Studio 3.4
distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip
Android Studio 2.3 distributionUrl=https\://services.gradle.org/distributions/gradle-2.3-all.zip
Android Studio 2.2 distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip
Android Studio 2.1 distributionUrl=https\://services.gradle.org/distributions/gradle-2.12-all.zip
Android Studio 2.0 distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip
Android Studio 1.5 distributionUrl=https\://services.gradle.org/distributions/gradle-2.8-all.zip
Android Studio 1.3 distributionUrl=https\://services.gradle.org/distributions/gradle-2.4-all.zip
You can find the latest Gradle wrapper version visiting:
https://services.gradle.org/distributions/
EDIT:
As a side note, as #SeBsZ suggests,
the official repository of the Android Gradle plugin switched from MavenCentral to jCenter (see Bintray blog post).
Make sure your project build.gradle file contains the new repository and the new classpath:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.0'
}
}
allprojects {
repositories {
jcenter()
}
}
This is not strictly related to the question problem, but since we are already migrating to the new IDE preview it's better to make sure everything is in place.
If, like me, you are using an older project then you might still be using the maven repository. Make sure you change the repositories in your top-level build.gradle from maven() to jcenter(). Then make sure you are using the correct dependency as well: classpath 'com.android.tools.build:gradle:1.3.0-beta1' for the new 1.3 preview.
For me helped to set chmod on the .gradle directory to 777. After this whole Android studio started working correctly.
I got the same issue after updating android studio to 3.4
I resolve this updatig gradle-wrapper.properties
I had
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
I leave
distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip
and with this To solve the Gradle sync error.
This is the weirdest thing ever and I never expected it to work but this:
distributionUrl=https://services.gradle.org/distributions/gradle-2.2.1-all.zip
worked and got everything fixed (it was the '\' after https). It does make sense since that is an actual link to a file.
check your .bash_profile file and make sure your GRADLE_HOME points to a valid path, if things were working and you face this issue after android studio update, chances are your gradle got updated too.
Here is the example of my gradle home in .bash_profile:
export GRADLE_HOME=/Applications/Android\ Studio.app/Contents/gradle/gradle-2.14.1/bin
Had the same problem with a newly set up Android Studio 2.2.2, gradle wrapper 2.14.1. I loaded the project before i installed the needed android-23 library and installed java after Android Studio installation.
Error message in Android Studio 2.2.2:
Error:The specified Gradle distribution
'https://services.gradle.org/distributions/gradle-2.14.1-all.zip' does
not appear to contain a Gradle distribution.
Error message in cmd:
projectfolder> gradlew
Exception in thread "main" java.lang.NullPointerException
at org.gradle.wrapper.BootstrapMainStarter.findLauncherJar(BootstrapMainStarter.java:34)
at org.gradle.wrapper.BootstrapMainStarter.start(BootstrapMainStarter.java:25)
at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:129)
at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:61)
When i used gradle from cmd however it worked
projectfolder> set PATH=%PATH%;C:\AndroidStudio2.0\gradle\gradle-2.14.1\bin\
projectfolder> set GRADLE_HOME=C:\AndroidStudio2.0\gradle\gradle-2.14.1\bin\
projectfolder> cd C:\projectfolder\
projectfolder> gradle
BUILD SUCCESSFUL
In cmd i see that the gradle versions and android sdk version were correct
C:\>set | find "JAVA_HOME"
JAVA_HOME=C:\Java\jdk1.8.0_111\
However in C:\Users\.AndroidStudio2.2\system\log\idea.log it said something else:
2016-11-29 16:04:10,597 [ 107684] INFO - s.plugins.gradle.GradleManager - Instructing gradle to use java from C:/AndroidStudio2.0/jre
2016-11-29 16:04:10,597 [ 107684] INFO - s.plugins.gradle.GradleManager - Instructing gradle to use java from C:/AndroidStudio2.0/jre
After messing up Android Studio config files i ended up reinstalling everything in correct order (Java, Android Studio, Project) and it worked.
I got the same issue after updating my android studio to 1.5
Here is my error stack trace.
Error:A problem occurred configuring root project 'Kargo'.
java.io.FileNotFoundException: /home/adiyatmubarak/Documents/android-studio/gradle/gradle-2.4/lib/plugins/gradle-diagnostics-2.4.jar (No such file or directory)
After I checked to the android studio instalation directory within gradle, my gradle was gradle-2.8 I don't know how to setup my android studio path location, but for temporary fix I just rename it to gradle-2.4 and my problem solved.

Resources