Updated android studio and got fail with Gstreamer build - android-studio

Updated to Android Studio 3.0.0 with new android gradle plugin.
While buildin project got message:
What went wrong:
Execution failed for task `':app:externalNativeBuildDebug'`.
Expected output file at `gst-build-arm64-v8a/libgstreamer_android.so` for target `gstreamer_android` but there was none
but libgstreamer_android.so library file is already there. For native code I use ndk-build. Does anyone have this issue?

Add to build.gradle file of our android module field targets.
android {
defaultConfig {
externalNativeBuild {
ndkBuild {
targets "name_of_native_module_in_android_mk_file"
}
...
}
Don't add gstreamer_android.

UPDATE: Valery's answer works!
Obsolete answer:
That's not the perfect fix, it's just temporary until I have time to take a deep look into the problem. Downgrade your gradle plugin:
File -> Project Structure
Click at "Project"
At "Gradle version" field put:
3.3
At "Android Plugin Version" field put:
2.3.3
Hit "OK"
Accept the messages, sync the project, etc... Android Studio may prompt a windown asking for update gradle plugin again, just don't accept it for now...
I guess the update on gradle changed the way the builds are made, maybe something on Android.mk will have to change or some other parameter on build.grade...
edit: I found some clue at: https://developer.android.com/studio/build/gradle-plugin-3-0-0-migration.html
API changes Android plugin 3.0.0 introduces API changes that removes
certain functionalities and may break your existing builds. Later
versions of the plugin may introduce new public APIs that replace
broken functionalities.
Modifying variant outputs at build time may not work Using the Variant
API to manipulate variant outputs is broken with the new plugin. It
still works for simple tasks, such as changing the APK name during
build time, as shown below:...
So, I guess we should keep using the temporary fix (not updated version of gradle)...

Related

What is the use of com.diffplug.spotless plugin in Android Studio?

I am working with Jetpack Compose and I came across "com.diffplug.spotless" plugin in the app's build.gradle file of many examples, but I am not sure if I need it in my project. Can anyone explain the purpose of using it in the Jetpack compose projects?
''' apply plugin: "com.diffplug.spotless" '''
Spotless: Keep your code spotless with Gradle
While working, Many a times you will get formatting issues at the stage of every commit like removing empty lines, cutting white spaces correct, indentation and other minor formatting mistakes.
Using tool/plugin called “Spotless” will reduce time in addressing code review comments.
Spotless provides support for a variety of languages.
Spotless consists of a list of format and each format has:-
1.a target (the files to format), which you set with target.
2.a list of FormatterStep, which are just String -> String functions, such as replace, replaceRegex, trimTrailingWhitespace, custom, prettier, eclipseWtp, licenseHeader etc.
To start integration with Gradle:-
1.Add the following dependency to your build.gradle file
classpath(“com.diffplug.spotless:spotless-plugin-gradle:$spotlessVersion”)
2.Apply the following plugin
apply plugin: ‘com.diffplug.gradle.spotless’
3.Applying spotless to your gradle file in Android Java source
spotless {
java {
// ...
target '**/*.java'
// ...
}
}
Note:- Be sure to add target '**/*.java' otherwise spotless will not detect Java code
inside Android modules.
For more detail you can refer this link : 1

Android Studio Kotlin databinding: Unresolved reference on BR

I have some code that is generating a "red squiggly" error in Android Studio:
#get:Bindable
var title: String = ""
set(value) {
field = value
notifyPropertyChanged(BR.title)
}
It complains that "title" is an unresolved reference on BR.title. Building and running works fine though, and this is the only error I can see. I debug there and see that it's gotten the value for BR.title correctly.
Still, I can't figure out how to make it go away. I verified that the generated BR class has the "title" field, but Android Studio refuses to recognize this. I've looked up people having this issue and have tried the following: (unsuccessfully)
Closing Android Studio, deleting the .gradle, .idea and build folders and restarting
Build -> Clean Project, Rebuild Project
File -> Invalidate Caches and restart
Disabling and enabling the Kotlin plugin
Closing and reopening the project
I have also checked and I have apply plugin: 'kotlin-kapt' in build.gradle.
Anyone know what's going on? I assume it must be holding onto some cache files somewhere but I don't know where.
What fixed the problem for me was adding the following import to my files:
import androidx.databinding.library.baseAdapters.BR
I'm not entirely certain why this works, but it got rid of all the analysis problems and the application still compiles and works fine, so I'm personally happy.

Android Studio Error retrieving parent for item: No resource found that matches the given name 'Theme.AppCompat.Light'

I'm using Android Studio 1.5.1 and I did was i renamed a working project with a new package. After that, I encountered the problem i mentioned above.
I can't for the life of me figure out how to fix this. I've tried adding the dependency files already. All of the solutions points to editing build.gradle file but I don't have that file because this project is imported from a eclipse project. Can anyone help me please?
Regards,
Dexter
If you want to add dependency,follow the steps below.
1.file->new->Import Module.
after import module
2.file->Project Structure->app->dependency tab-> add library dependencies.
3.In build.gradle(your module) change to apply plugin: 'com.android.library'
if you get any error regarding min and target sdk versions, then choose 4th step other wise exclude 4th step(first 3 step enough).
4.file->Project Structure->example ->Flavors tab //change minimum and target sdk versions().

ProGuard issues with Android Archieve(.aar) library

I've a library project which I want to distribute, in AAR format. I've applied ProGuard on it.
ProGuard settings works well if I use this lib as a module, but not when I use resulting AAR. Basically it fails with exception "java.lang.IllegalArgumentException: already added Lmy/lib/package/name/R;" in Application project.
ProGuard is renaming one of my lib class to R, and I feel which is causing problem in Application project as R is used for Resources.
How do I specify proguard mapping in Studio to tell it not to rename to R.
Update:
after adding AAR file as a new module, am getting this error:
UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexException: Multiple dex files define Lmy/lib/package/name/R;
at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:596)
at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:554)
at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:535)
at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:171)
at com.android.dx.merge.DexMerger.merge(DexMerger.java:189)
at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:454)
at com.android.dx.command.dexer.Main.runMonoDex(Main.java:303)
at com.android.dx.command.dexer.Main.run(Main.java:246)
at com.android.dx.command.dexer.Main.main(Main.java:215)
at com.android.dx.command.Main.main(Main.java:106)
Okay then, answering myself.
Tried running ProGuard manually on .aar, worked with latest version v5.2.1. Didn't work with default version v4.7 which came with Studio v1.2.2. Hope this helps.

Intellij + Gradle: Import classes automatically

I am writing a gradle build file. I want to use the dependency Apache Commons Net v3.3.
Now, whenever I type a statement that uses a class from this dependency, IntelliJ does not recognize that I am missing a import. I was aldo not offered any classes from the previously added dependency. I did indeed click the refresh button on the gradle tab in IntelliJ IDEA, before I added any dangling content to my buildscript.
When I run gradlew now (and it compiles the buildscript), I get a error about a unrecognized Symbol.
Can I do something to make IntelliJ report missing imports to me?
I can add the import by looking up the javadoc online any manually copy-pasting the class name into my buildscript, but I find that rather annoying and I think that such primitive tasks should be done by a IDE.
This is pretty much the exact example:
apply plugin: 'java'
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'commons-net:commons-net:3.3'
}
}
task example << {
FTPClient ftp = new FTPClient() //IntelliJ does not complain about missing imports, neither did it have the correct class available in auto-completion
}
Install the gradle plugin (which it seems like you already have).
Go to the gradle tab on the right side of the IDE and click the wrench icon to get to gradle settings.
Check the box that says "Use auto-import"

Resources