Comments (29)
There is definitely a packaging problem with version 0.0.1
of the library. It includes all class files of the dependencies (including the support library, Guava files, OkHttp, ...):
The exclude group
statements for debugImplementation
suggested above won't work in this case. They only work for dependencies that are declared in the pom file (sonar-0.0.1 does not declare any dependencies there - they are all bundled inside of the aar).
The only way I could get it to work is to manually extract the aar file (and the contained classes.jar file), repackage them, then directly reference them in my build.gradle file.
It went something like this:
mkdir -p ~/tmp/sonar-0.0.1
cp ~/.gradle/caches/modules-2/files-2.1/com.facebook.sonar/de84b64d6ab7a9b71e80875f5fb6cabf040eb06/sonar-0.0.1.aar ~/tmp/sonar-0.0.1/
cd ~/tmp/sonar-0.0.1
unzip sonar-0.0.1.aar -d aar-0.0.1
cp aar-0.0.1/classes.jar .
unzip classes.jar -d classes-0.0.1
# Now delete all the unwanted packaged class files, e.g.
rm -rf classes-0.0.1/android classes-0.0.1/javax classes-0.0.1/jsr-305
# Repackage classes file
jar cvf classes.jar -C classes-0.0.1/ .
# Repackage aar file
cp classes.jar aar-0.0.1/
jar cvf sonar-0.0.1-LOCAL.aar -C aar-0.0.1/ .
# Now use the new aar file directly:
cp sonar-0.0.1-LOCAL.aar ~/path/to/android-project/app/libs
# build.gradle
allprojects {
repositories {
google()
jcenter()
flatDir {
dirs 'libs'
}
}
}
# app/build.gradle
dependencies {
// ...
debugImplementation(name: 'sonar-0.0.1-LOCAL', ext: 'aar')
}
from flipper.
I have a hard time understanding how the Sonar library in its current form would work with any external real application out there. I am facing similar issue but with OkHttp3
Program type already present: okhttp3.Authenticator$1
Message{kind=ERROR, text=Program type already present: okhttp3.Authenticator$1, sources=[Unknown source file], tool name=Optional.of(D8)}
And since OkHttp3 is pretty common [sarcasm], how on earth can Sonar in its current form work in real production apps? So this library has to be slimmed down and not ship with all these baked in dependencies.
from flipper.
looks like sonar has all dependencies packaged inside of it. try to implement like this
debugImplementation ('com.facebook.sonar:sonar:0.0.1'){
exclude group: 'android'
exclude group: 'javax'
exclude group: 'jsr-305'
exclude group: 'okhttp3'
exclude group: 'okio'
exclude group: 'org'
exclude group: 'com.google'
}
from flipper.
I tried to use the following snippet (I can't remember where it was from, I used it in a past project)
configurations.all {
resolutionStrategy.eachDependency { DependencyResolveDetails details ->
def requested = details.requested
if (requested.group == "com.android.support") {
if (!requested.name.startsWith("multidex")) {
details.useVersion "27.+"
}
}
}
}
But that din't seem to solve the issue.
from flipper.
I've got the similar error in the Android Issues
section:
Program type already present: okio.Util
Message{kind=ERROR, text=Program type already present: okio.Util, sources=[Unknown source file], tool name=Optional.of(D8)}
from flipper.
@sgrekov You can get them from by adding https://oss.sonatype.org/content/repositories/snapshots/
as repository. But thanks for pointing that out; that should not be necessary.
I'll bump the Litho dependencies back to stable and push out another release with them included.
from flipper.
@passy Hi, got an error, found both libs have libsonarfb.so
after unpack the aar
.
Execution failed for task ':mobile:transformNativeLibsWithMergeJniLibsForDebug'.
> More than one file was found with OS independent path 'lib/armeabi-v7a/libsonarfb.so'
from flipper.
Hope that the official can provide AAR file
from flipper.
@erawhctim Hmm, is it possible that your existing dependencies have some conflict?
Try
./gradlew :app:dependencies
I assume you already completely cleaned the project after modifying the aar file, to remove any chance for cached file problems? You may also try ./gradlew --stop
to stop running instances the Gradle wrapper (although unlikely related to that).
from flipper.
@Swordsman-Inaction You can add the following
packagingOptions {
pickFirst 'lib/armeabi-v7a/libsonarfb.so'
pickFirst 'lib/x86/libsonarfb.so'
pickFirst 'lib/x86_64/libsonarfb.so'
pickFirst 'lib/arm64-v8a/libsonarfb.so'
}
from flipper.
One more try. :) Published 0.0.8
which no longer includes two copies of libsonarfb.so
, so you don't have to use pickFirst
or other hacks. x86_64
is still not supported, but we're looking into that as part of #111 as we're trying to find a version of OpenSSL that's compatible with folly and compiles with modern NDK versions.
from flipper.
@TurKorsaN I couldn't get it to work, the same error is thrown (even after cleaning and trying to re-build)
from flipper.
I have the same issue:
AGPBI: {"kind":"error","text":"Program type already present: androidx.fragment.app.FragmentManager$OnBackStackChangedListener","sources":[{}],"tool":"D8"}
from flipper.
I have the same issue:
- What went wrong:
Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.
com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives:
from flipper.
@jiangkang This just means you have other conflicting dependencies. The steps above only removed the support library, annotations and a few other things. Your project might have dependencies on OkHttp
or Okio
, for example. You'll need to remove those as well.
from flipper.
@friederbluemle Thanks for the tip!
I followed your steps and was able to strip out the duplicated javax classes that gradle/D8 was complaining about, but I'm still seeing a similar error - D8: Program type already present: javax.annotation.concurrent.ThreadSafe
(even though I've double checked and removed all the javax.*
classes before recompiling as a local AAR.
Any ideas?
from flipper.
@friederbluemle Hmm, I think you might be right. Looks like realm-android-library
depends on FindBugs' JSR305 so maybe the javax.*
classes are coming in from there.
debugCompileClasspath - Resolved configuration for compilation for variant: debug
+--- io.realm:realm-annotations:5.3.0
+--- io.realm:realm-android-library:5.3.0
| +--- com.google.code.findbugs:jsr305:3.0.2
| +--- com.getkeepsafe.relinker:relinker:1.2.2
| \--- io.realm:realm-annotations:5.3.0
+--- io.realm:realm-android-kotlin-extensions:5.3.0
| \--- org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.2.10
| \--- org.jetbrains.kotlin:kotlin-stdlib:1.2.10
| \--- org.jetbrains:annotations:13.0
+--- project :sonar-0.0.1-LOCAL
+--- org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.2.10 (*)
\--- org.jetbrains.anko:anko-commons:0.10.4
\--- org.jetbrains.kotlin:kotlin-stdlib:1.1.0 -> 1.2.10 (*)
I tried excluding that from the realm gradle plugin declaration like this, but that didn't work like I expected it to:
classpath("io.realm:realm-gradle-plugin:5.3.0") {
exclude group: 'com.google.code.findbugs', module: 'jsr305'
}
from flipper.
met the same issue again:
:app:transformDexArchiveWithExternalLibsDexMergerForDebug
-- | --
how can I fix ???
from flipper.
@priteshrnandgaonkar and I are still working on a full solution, but we've got a stop-gap that should already help a great deal.
If you include this repository (while we're waiting for JCenter to approve a new package) ...
repositories {
maven { url 'https://dl.bintray.com/facebook/maven/' }
}
... and depend on ...
debugImplementation 'com.facebook.sonar:sonar:0.0.4
... then you should be able to use Sonar in your Android project. For now we DO NOT support x86_64
due to an OpenSSL compilation issue, but armv7
, armv8
and x86
should all work just fine.
from flipper.
Another update on this: The extra repository is no longer necessary as the new dependency got promoted into JCenter proper.
from flipper.
com.facebook.sonar:sonar:0.0.4 depends on
+--- com.facebook.litho:litho-core:0.15.1-SNAPSHOT
| +--- com.facebook.litho:litho-widget:0.15.1-SNAPSHOT
But they are not on jcenter nor on the https://dl.bintray.com/facebook/maven/
from flipper.
Pushed 0.0.5
which no longer depends on Litho snapshots.
from flipper.
@passy Don't forget to push com.facebook.sonar:fbjni
too. 0.0.5
is currently not available but required by the lib.
from flipper.
@Swordsman-Inaction Thanks! The task silently failed to publish the release because the javadoc generation failed with an odd error. Uploading now.
from flipper.
@Swordsman-Inaction The workaround from @priteshrnandgaonkar should work, but it's still something we shouldn't force you to do. I'll try to exclude the library from getting bundled into the sonar
AAR. Pulling it in from one place should be enough.
from flipper.
Is this issue resolved? I still face it.
from flipper.
maven { url 'https://dl.bintray.com/facebook/maven/' }
debugImplementation 'com.facebook.sonar:sonar:0.0.9'
from flipper.
Yes, the newer versions address this. Closing this here now. :)
from flipper.
I have solved my issue by using this configurations in gradle file. You save my day. Thanks !
from flipper.
Related Issues (20)
- Plugin Hermes Debugger (RN) unavailable HOT 18
- Flipper shows white screen after loading, reloading won't fix it HOT 4
- GitHub Actions Workflow failed - Publish
- GitHub Actions Workflow failed - Publish Android
- GitHub Actions Workflow failed - Publish
- Website UI responsiveness improvement is needed HOT 1
- GitHub Actions Workflow failed - Publish
- GitHub Actions Workflow failed - Publish
- flipper crash
- Plugin 'React DevTools' is unavailable in 0.239.0 HOT 2
- UI bug in flipper 0.239.0 HOT 1
- Flipper does not work on Windows HOT 10
- LeakCanary plugin not showing anything
- Flipper's latest release's mac's aarch64 build not opening up in mac sonoma HOT 1
- Flipper
- Seeking Help with Hermes Debugger (RN) Issue HOT 2
- npx flipper-server doesn't run HOT 7
- Watchman was not found HOT 5
- Discussion: New MacOS icon for Desktop app HOT 1
- npm i fails because of requested [email protected] is not available
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from flipper.