AndroidStudio 4.1 Problem with Sourcesets - android-studio

AndroidStudio version: 4.1
Device: MacBook Pro MacOs 10.15.7
Step1: new a example project
Step2: new a module named mylibrary
Step3: create 'api' dir at mylibrary/src/main
Step4: modify build.gradle in app as followed
android {
...
sourceSets{
main{
java.srcDirs "${rootDir}/mylibrary/src/main/api"
}
}
}
mylibrary cannot recognize java file!

I had loads of issues with the new android 4.1 update I then updated the version to Android Studio 4.1 RC 2 https://developer.android.com/studio/archive the link to the download is there give it a try if it don't work just go back to 4.0

Related

Android Studio 4.2 #Generated not found

I get this issue when trying to compile an Android project with Dagger2 while using the new Android Studio version 4.2.
Solved by using: compileOnly 'com.github.pengrad:jdk9-deps:1.0' for each module that uses Dagger.

How i can build old Android project in Android Studio

i have to build this project but getting error because it is so old.
here is the project git hub link
i am using latest android studio version
Try the following:
Change gradle version in build.gradle , change the version in the following line in the file: classpath 'com.android.tools.build:gradle:2.2.3'.
In the file gradle/wrapper/gradle-wrapper.properties, update the gradle version in this line: distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip . Sync the project again, it should work. If it doesn't restart android studio again. It should build successfully afterward.
PS: See what gradle version you use according to your android studio version.

Android Studio 4.0 file > New > Activity OR Fragment not working

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.

Android Studio stuck installing application to Device after add jar library

I'm setting up a SignalR client with Android. I'm using Android Studio 3.3 with Gradle v3.0.1.
I'm using two SignalR deprecated jar library in project.
- signalr-client-sdk.jar
- signalr-client-sdk-android.jar
The problem starts after adding these two jar dependencies to project.
After adding jar libs, Android Studio suck in installing application on device.
I did same thing in other project on my friend's PC and it works. I don't know whats wrong with this?
=====
UPDATE
I tried with an other device... I installed GenyMotion Emulator and Created several kind of Virtual Machines.
Android Studio is going to install the application on vm with api level 16 but when trying to install on vm with api level 27(8.1) it stuck again.
Screenshot :
I could generate signed apk and install on phone. but can't install directly from Android studio.
UPDATE
Add these lines to your build.gradle of app module, within the android { }:
android {
splits {
abi {
enable true
reset()
include 'x86', 'x86_64', 'armeabi', 'armeabi-v7a', 'mips', 'mips64', 'arm64-v8a'
universalApk true
}
}
packagingOptions {
exclude 'lib/getLibs.ps1'
exclude 'lib/getLibs.sh'
exclude 'lib/gson-2.2.2.jar'
}
}
Old Answer
Try these steps:
Step One: Add this dependency to your build.gradle:
implementation 'com.microsoft.signalr:signalr:1.0.0'
Step Two: Add these lines to your activity:
private final String serverUrl = "put your server url";
private HubConnection hubConnection;
hubConnection = HubConnectionBuilder.create(serverUrl).build();
if (hubConnection.getConnectionState() == HubConnectionState.DISCONNECTED)
hubConnection.start();
if (hubConnection.getConnectionState() == HubConnectionState.CONNECTED)
hubConnection.send("your method name at server", your arguments);
else if (hubConnection.getConnectionState() == HubConnectionState.DISCONNECTED)
hubConnection.start();
As you see at above, you don't need to add two signalR deprecated jar library in project.

This version of Android Studio cannot open this project, please retry with Android Studio 3.5 or newer

This version of Android Studio cannot open this project, please retry with Android Studio 3.5 or newer.
but my android studio version is 3.3.1 and there is no new update from Google
Change Project level gradle as below -
classpath 'com.android.tools.build:gradle:3.3.1'
Change gradle-wrapper.properties as below -
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip
Hope this will work...
Just Change the classpath to the version of your Android Studio Version.
To Find Version :
Click on help > About > Version is visible.
It will download the Gradle according to your android studio version.
Eg :
If your android studio version is 3.3.2 then change as follow :
classpath 'com.android.tools.build:gradle:3.3.2'
You would need to lower your gradle version in your project build.gradle file.
Hope it helps...

Resources