How to import ActionBarSherlock using Gradle in Android app? - java

I'm trying to import ActionBarSherlock (ABS) into my Android app using Gradle, but unfortunately, when building I get a list of errors saying:
/Users/kramer65/dev/repos/android-official/OurPackage/build/res/all/debug/values/values.xml:248: error: Attribute "titleTextStyle" has already been defined
/Users/kramer65/dev/repos/android-official/OurPackage/build/res/all/debug/values/values.xml:250: error: Attribute "subtitleTextStyle" has already been defined
/Users/kramer65/dev/repos/android-official/OurPackage/build/res/all/debug/values/values.xml:256: error: Attribute "divider" has already been defined
/Users/kramer65/dev/repos/android-official/OurPackage/build/res/all/debug/values/values.xml:258: error: Attribute "background" has already been defined
[etc. etc.]
* What went wrong:
Execution failed for task ':processDebugResources'.
> Could not call IncrementalTask.taskAction() on task ':processDebugResources'
I'm trying to import ABS using the following in build.gradle:
dependencies {
compile 'com.actionbarsherlock:actionbarsherlock:4.4.0#aar'
compile 'com.android.support:support-v4:18.0.+'
compile 'com.google.android.gms:play-services:4.0.30'
instrumentTestCompile(files('libs/espresso-1.0-SNAPSHOT-bundled.jar'))
}
and in my settings.gradle I've got the following line:
include ':OurPackage', ':Libraries:ActionBarSherlock'
Does anybody know what I'm doing wrong? All tips are welcome!

The same attributes titleTextStyle, subtitleTextStyle, divider, background are defined in 2 different libraries.
The 'com.actionbarsherlock:actionbarsherlock:4.4.0#aar' and the support library 'com.android.support:support-v4:18.0.+' which introduced the v7 appcompat library can't work together.

Related

Duplicate class caused by Android Gradle plugin

I'm having some trouble with Gradle and Android Studio. When trying to compile the dependency com.nukkitx.protocol:bedrock-v407:2.6.0-SNAPSHOT I'm getting duplicate class errors, but when compiled in a normal desktop Gradle project it compiles fine. Any help would be greatly appreciated.
Code: https://github.com/rtm516/GeyserAndroid
Error:
Duplicate class it.unimi.dsi.fastutil.ints.IntIterator found in modules jetified-fastutil-common-8.3.1.jar (com.nukkitx.fastutil:fastutil-common:8.3.1) and jetified-fastutil-int-common-8.3.1.jar (com.nukkitx.fastutil:fastutil-int-common:8.3.1)
Duplicate class it.unimi.dsi.fastutil.longs.LongIterator found in modules jetified-fastutil-common-8.3.1.jar (com.nukkitx.fastutil:fastutil-common:8.3.1) and jetified-fastutil-long-common-8.3.1.jar (com.nukkitx.fastutil:fastutil-long-common:8.3.1)
Duplicate class it.unimi.dsi.fastutil.objects.ObjectIterator found in modules jetified-fastutil-common-8.3.1.jar (com.nukkitx.fastutil:fastutil-common:8.3.1) and jetified-fastutil-object-common-8.3.1.jar (com.nukkitx.fastutil:fastutil-object-common:8.3.1)
Managed to fix this by using https://github.com/shevek/jarjar and removing the duplicate classes using the below.
implementation jarjar.repackage {
from 'com.nukkitx.fastutil:fastutil-common:8.3.1'
classDelete "it.unimi.dsi.fastutil.ints.IntIterator"
classDelete "it.unimi.dsi.fastutil.longs.LongIterator"
classDelete "it.unimi.dsi.fastutil.objects.ObjectIterator"
}

Why does implementing the Cloneable Interface in a Kotlin class result in "error: no interface expected here"?

I'm resuming work on an Android app that I haven't touched for a year. It used to build fine at the time. Now when I open it in Android Studio it complains that various libs, plugins, etc. are out of date. Trying to fix this myself, I couldn't get rid of all the sync/build errors, so in the end I updated Android Studio (from around 3.3, I think) to 3.5.2 and let it update whatever plugins etc. it wanted to.
Then I ran into issues indicating I should migrate from the old support packages to AndroidX (don't remember the details). To migrate, I then did the following:
Set compileSdkVersion to 28 for all modules
In all modules' build.gradle, updated the dependencies to 28
Added android.useAndroidX=true and android.enableJetifier=true to gradle.properties
Ran Refactor | Migrate to AndroidX...
Now Gradle sync works, but building fails with this error:
> Task :app:kaptDebugKotlin FAILED
e: [...]\app\build\tmp\kapt3\stubs\debug\com\[...]\MyClass.java:9: error: no interface expected here
public final class MyClass extends java.lang.Cloneable {
^
FAILURE: Build failed with an exception.
The above error is in generated code. My code, from which the above is generated, looks like this:
// MyClass.kt
class MyClass : Cloneable {
...
}
I understand java.lang.Cloneable is an interface, and the generated code has extends instead of implements. But as mentioned, this used to work, so what am I doing wrong?
I took another look at the project-level build.gradle and found it. Android Studio was suggesting to update the Kotline version again. I changed it to
ext.kotlin_version = '1.3.61'
and now I can compile.

Importing missing package (sun.security.pkcs.PKCS10) automatically in Android Studio

I have to use PKCS10 class into my project. I tried to import sun.security.pkcs.PKCS10; into my activity code but studio shows "Cannot resolve symbol PKCS10" at both places where I have imported it and where I want to instantiat it.
Note: I haven't added any dependency or library (like .jar) to my project.
I want to know whether can it be automatically?
The class sun.security.pkcs10.PKCS10 was removed from the JDK. Using a class that was internal and already removed from the JDK is going a step beyond just using an internal API.
Put this into your build.gradle file.
compileJava {
options.forkOptions.javaHome = file(System.properties['java.home'])
}
And if this does not work, put this into you build.gradle(app) dependencies.
compile group: 'com.sun', name: 'rt', version: '1.5.0_06'

How to append /META-INF/BenchmarkList to jmh task to fix "ERROR: Unable to find the resource: /META-INF/BenchmarkList"

I'm new to micro bench-marking in general. When I execute the JMH task in my project I get "ERROR: Unable to find the resource: /META-INF/BenchmarkList", I believe is created by jmh-generator-annprocess. I am using Gradle and I am trying to figure out if jmh-generator-annprocess is even working? Will it work properly for Gradle or do I need to use the Maven plugin or something?
https://github.com/coderrick/JMH-Studies.git in case you want to git clone my project and run it yourself.
There was a couple of issues
JMHSample_02_BenchmarkModes class was in incorrectly named java class
build.gradle was missing apply plugin: "me.champeau.gradle.jmh" declaration
In jmhJar section Main-Class manifest entry was overridden (which is unnecessary)
I've made a PR with above fixes. After applying it you can run performance tests using
java -jar build/libs/JMH-Studies-jmh.jar

Imported existing Android project error on eclipse

I've got many errors on my project recently which I'd imported on eclipse.
The project build target is Android 2.3.3 (API Level 10) and minSdkVersion, targetSdkVersion
is "9" and "14" respectively. In addition, Zip_file, library(licensing), and (Google Play) downloader_library have been added to the project.
The point is I have no idea with the errors appeared.
Window -> Show Views -> Problems -> 4errors (4items)
Project 'downloader_library' is missing required library :'/Users/Documents/Folder/downloader_library/bin/downloader_library.jar'
The Container 'Android Dependencies' references non existing library'/Users/Documents/Folder/downloader_library/bin/downloader_library.jar'
The project cannot be built until build path errors are resolved
The project cannot be built until build path errors are resolved
You know what I've put the 'downloader_library.jar' as the same path above but errors are still exist.
Errors extra :
com.google.android.vending.expansion.downloader.impl/downloader_library/V14CustomNotification
Notification.Builder cannot be resolved to a type
Multiple markers at this line - Notification.Builder cannot be resolved to a type
- Notification.Builder cannot be resolved to a type
project/package/
The hierarchy of the type MainActivity is inconsistent
ICE_CREAM_SANDWICH cannot be resolved or is not a field
SYSTEM_UI_FLAG_LOW_PROFILE cannot be resolved or is not a field
The hierarchy of the type MarketActivity is inconsistent
The import android.nfc.NfcAdapter.CreateNdefMessageCallback cannot be resolved
The import android.nfc.NfcEvent cannot be resolved
The import com.google.android.vending.expansion cannot be resolved
The import com.google.android.vending.expansion cannot be resolved
CreateNdefMessageCallback cannot be resolved to a type
The method setNdefPushMessageCallback(MuseumActivity, MuseumActivity) is undefined for the type NfcAdapter
Helpers cannot be resolved
DownloaderClientMarshaller cannot be resolved
NfcEvent cannot be resolved to a type
DownloaderService cannot be resolved to a type
The method getPublicKey() of type ExpansionFileDownloaderService must override or implement a supertype method
The method getSALT() of type ExpansionFileDownloaderService must override or implement a supertype method
The method getAlarmReceiverClassName() of type ExpansionFileDownloaderService must override or implement a supertype method
All I want to do is just editing some codes in application but i can't even build this project. I've wasted 7days for this. What should I do. Please give me a help.
you can try this-
download latest android sdk from here, http://developer.android.com/sdk/index.html#download
open the sdk manager and install the libraries required for the project. make a new project. copy all the layout files in this new project, and then clean the project. now make new java files with same names and copy the code. create entries in manifest files. it should work now.
same problem existed for me. adding the libraries in java build path didn't work.

Categories