I have two github pacakges named XXX/AAA and YYY/BBB (same OWNER but different repository).
Now, when I try to add them into my project, gradle always seem to use the 1st repository.
repositories {
maven { url 'https://jitpack.io' }
maven {
url "https://maven.pkg.github.com/XXX/AAA"
credentials {
username = USERNAME
password = PWD
}
}
maven {
url "https://maven.pkg.github.com/XXX/BBB"
credentials {
username = USERNAME
password = PWD
}
}}
And com.example in implementation is also same.
dependencies {
// implementation 'com.example:package'
// AAA
implementation("YYY:AAA:${a_version}")
// BBB
implementation("YYY:BBB:${b_version}")
}
and I receive the following error while syncing
Could not HEAD 'https://maven.pkg.github.com/XXX/AAA/YYY/BBB/0.1/BBB-0.1.pom'. Received status code 400 from server: Bad Request. Disable Gradle 'offline mode' and sync project
As we can clearly see, gradle uses the wrong repository(AAA instead of BBB)
Any help is appreciated.
Thanks in advance
You need to declare these repositories as exclusive for the respectful dependencies:
repositories {
maven { url 'https://jitpack.io' }
exclusiveContent {
forRepository {
maven {
url 'https://maven.pkg.github.com/XXX/AAA'
credentials {
username = "USERNAME"
password = "PWD"
}
}
}
filter {
includeModule("YYY", "AAA")
}
}
exclusiveContent {
forRepository {
maven {
url 'https://maven.pkg.github.com/XXX/BBB'
credentials {
username = "USERNAME"
password = "PWD"
}
}
}
filter {
includeModule("YYY", "BBB")
}
}
}
Related
I'm upgrading the React Native version to the 0.69.3. And when I try to run on android. I get this error:
Using insecure protocols with repositories, without explicit opt-in, is unsupported. Switch Maven repository 'maven9(http://repo.brightcove.com/releases)' to redirect to a secure protocol (like HTTPS) or allow insecure protocols.
I tried the following solutions:
Add the allowInsecureProtocol = true param.
Just add the s on the http.
But still throw me this error.
This is my code in that part:
allprojects {
repositories {
mavenLocal()
maven {
url("$rootDir/../node_modules/react-native/android")
}
maven {
url("$rootDir/../node_modules/jsc-android/dist")
}
maven { url 'https://artifactory.img.ly/artifactory/imgly' }
mavenCentral {
content {
excludeGroup "com.facebook.react"
}
}
google()
jcenter()
maven { url 'https://repo.brightcove.com/releases' }
maven {
url "http://repo.brightcove.com/releases"
allowInsecureProtocol = true
}
maven { url 'https://maven.google.com' }
maven { url "https://www.jitpack.io" }
}
}
I have an error in console after to install expo-camera.
expo install expo-camera
add permission in android manifest
add module expo camera in maven
allprojects {
repositories {
// * Your other repositories here *
// * Add a new maven block after other repositories / blocks *
maven {
// expo-camera bundles a custom com.google.android:cameraview
url "$rootDir/../node_modules/expo-camera/android/maven"
}
}
}
start the protect
click on the button to show camera ... error in log
Error: Permissions module is null.
Permission:
<uses-permission android:name="android.permission.CAMERA" />
update 1 :
I test with this code example to check my permission
https://reactnative.dev/docs/permissionsandroid
my example function
// state local
const [hasPermission, setHasPermission] = useState(null);
// function
const requestCameraPermission = async () => {
console.log('requestCameraPermission')
try {
const granted = await PermissionsAndroid.request(
PermissionsAndroid.PERMISSIONS.CAMERA,
{
title: "Cool Photo App Camera Permission",
message:
"Cool Photo App needs access to your camera " +
"so you can take awesome pictures.",
buttonNeutral: "Ask Me Later",
buttonNegative: "Cancel",
buttonPositive: "OK"
}
);
if (granted === PermissionsAndroid.RESULTS.GRANTED) {
setHasPermission(true)
console.log("You can use the camera");
} else {
console.log("Camera permission denied");
setHasPermission(false)
}
} catch (err) {
console.warn(err);
}
};
// result of requestCameraPermission : You can use the camera
// Error : Attempt to invoke interface method 'boolan expo.modules.interfaces.permission.Permission.hasGrantedPermissions(java.lang.string[]) on a null object reference
I make something wrong ?
thanks for help
If you did just these steps, you have to do more things to make it works on Android device.
Github page says:
Adjust the android/build.gradle to add a new maven block after all other repositories as described below:
allprojects {
repositories {
// * Your other repositories here *
// * Add a new maven block after other repositories / blocks *
maven {
// expo-camera bundles a custom com.google.android:cameraview
url "$rootDir/../node_modules/expo-camera/android/maven"
}
}
}
But before do that, you should:
For bare React Native projects, you must ensure that you have installed and configured the react-native-unimodules package before continuing.
i am getting a authorization error when using mapbox in react native
https://api.mapbox.com/downloads/v1/navigation/android/maven/com/mapbox/navigation/ui/1.5.0/ui-1.5.0.pom'. Received status code 401 from server: Unauthorized
i am using the package ( https://www.npmjs.com/package/#homee/react-native-mapbox-navigation )
according package documentation i am doing the same.
my build.gradle file is
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext {
buildToolsVersion = "29.0.3"
minSdkVersion = 21
compileSdkVersion = 29
targetSdkVersion = 29
ndkVersion = "20.1.5948944"
}
repositories {
google()
jcenter()
maven {
url 'https://api.mapbox.com/downloads/v1/navigation/android/maven'
authentication {
basic(BasicAuthentication)
}
credentials {
username = "mapbox"
password = project.properties['MAPBOX_DOWNLOADS_TOKEN'] ?: ""
}
}
}
dependencies {
classpath("com.android.tools.build:gradle:4.1.0")
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
mavenLocal()
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url("$rootDir/../node_modules/react-native/android")
}
maven {
// Android JSC is installed from npm
url("$rootDir/../node_modules/jsc-android/dist")
}
google()
jcenter()
maven { url 'https://mapbox.bintray.com/mapbox' }
maven { url 'https://www.jitpack.io' }
maven {
url 'https://api.mapbox.com/downloads/v1/navigation/android/maven'
authentication {
basic(BasicAuthentication)
}
credentials {
username = "mapbox"
password = project.properties['MAPBOX_DOWNLOADS_TOKEN'] ?: ""
}
}
}
}
I recently encountered a similar issue. My first advice would be that if you're using their public Access token, create a new one from Access Tokens and make sure Downloads:Read scope is checked. Then create a gradle.properties file in "your_projects_directory.gradle" (which to me was C:\Users\USERNAME\AndroidStudioProjects\ .gradle), and paste the following line:
MAPBOX_DOWNLOADS_TOKEN=YOUR_SECRET_ACCESS_KEY
You should replace YOUR_SECRET_ACCESS_KEY with your actual access key of course. Just in case Android Studio is unable to find this newly created gradle.properties file, I would recommend adding a duplicate of the above line to your project gradle.properties file [This was what fixed my issue] although I'm not sure if this has any security implications.
Then finally your build.gradle should contain this:
maven {
url 'https://api.mapbox.com/downloads/v2/releases/maven'
authentication {
basic(BasicAuthentication)
}
credentials {
// Do not change the username below.
// This should always be `mapbox` (not your username).
username = 'mapbox'
// Use the secret token you stored in gradle.properties as the password
password = System.getenv("MAPBOX_DOWNLOADS_TOKEN") ?: project.property("MAPBOX_DOWNLOADS_TOKEN") as String
}
}
I currently have a problem with the file size of kotlin js. I have one multiplatform lib which has around 160Kb and integrate it in the kotlin js project. The kotlin js project itself does not have that much code.
After assembling (which should enable also DCE for shrinking) the Js file size is up to 2.5MB. I really don't know why it bloats up like that. I hope anybody has a clue. Following is my gradle.config, maybe I forgot something to add.
Short update:
We found out when serving the file of 2.5MB from CDN githack. The file is optimized to 500KB. How is that even possible. Does that mean that the actual DCE of kotlin isn't working at all?
plugins {
kotlin("js") version "1.4.10"
}
group = "me.at"
version = "1.0-SNAPSHOT"
repositories {
mavenLocal()
mavenCentral()
jcenter()
maven {
url = uri("https://dl.bintray.com/kotlin/kotlinx")
}
maven {
url = uri("https://dl.bintray.com/kotlin/kotlin-js-wrappers")
}
maven {
url = uri("https://dl.bintray.com/ekito/koin")
}
}
dependencies {
implementation(kotlin("stdlib-js"))
implementation("org.jetbrains:kotlin-styled:1.0.0-pre.110-kotlin-1.4.10")
implementation(npm("styled-components", "~5.1.1"))
implementation(npm("inline-style-prefixer", "~6.0.0"))
implementation("com.mp.multi:multi:1.1")
implementation("org.koin:koin-core:3.0.0-alpha-4")
implementation(npm("html-webpack-plugin", "3.2.0"))
}
kotlin {
js {
browser {
binaries.executable()
webpackTask {
cssSupport.enabled = true
}
runTask {
cssSupport.enabled = true
}
testTask {
useKarma {
useChromeHeadless()
webpackConfig.cssSupport.enabled = true
}
}
}
}
}
I created a free artifactory server on Google Cloud and I'm trying to deploy it, but I have the following error:
Execution failed for task ':artifactoryDeploy'.
java.io.IOException: Could not publish build-info: This plugin is compatible with version 2.2.3 of Artifactory and above. Please upgrade
your Artifactory server!
My Gradle config
import groovy.lang.GroovyObject
import org.jfrog.gradle.plugin.artifactory.dsl.PublisherConfig
plugins {
kotlin("jvm") version "1.4.10"
id("com.jfrog.artifactory") version "4.17.2"
`maven-publish`
}
group = "com.rjdesenvolvimento"
version = "0.0.1"
repositories {
jcenter()
maven { url = uri("https://kotlin.bintray.com/ktor") }
}
dependencies {
implementation(kotlin("stdlib"))
api("org.junit.jupiter:junit-jupiter-engine:5.7.0")
api("org.jetbrains.kotlin:kotlin-test-junit5:1.4.10")
api("io.mockk:mockk:1.10.2")
}
tasks {
compileKotlin { kotlinOptions.jvmTarget = "11" }
compileTestKotlin { kotlinOptions.jvmTarget = "11" }
}
publishing {
publications {
create<MavenPublication>("kotlin") {
from(components["kotlin"])
}
}
}
artifactory {
setContextUrl("https://some-addressjfrog.io/artifactory/artifact/")
publish(delegateClosureOf<PublisherConfig> {
repository(delegateClosureOf<GroovyObject> {
setProperty("repoKey", "aries-develop")
setProperty("username", "some-user")
setProperty("password", "some=password")
setProperty("maven", true)
})
})
}
The issue is with using a wrong Artifactory URL (as indicated by #yahavi in the comments).
Please make sure that you are using the root Artifactory context, for example:
https://some-address.jfrog.io/artifactory/
The error message from the plugin is misleading and is updated in version 3.9.0 of the Jenkins Artifactory plugin.For more details see this Github issue.