uiwjs / react-native-alipay

基于 React Native 的宝支付包,已更新到最新的支付宝 SDK 版本,支持Android/iOS。
https://uiwjs.github.io/react-native-alipay/
MIT License
208 stars 49 forks source link

failed configuration with name 'compile' not found #55

Closed qilovehua closed 2 years ago

qilovehua commented 2 years ago

sync projects with gradle files时报错了。 Android Gradle Plugin Version: 7.0.4, Gradle version: 7.0.2

只能降版本吗?
Android Gradle Plugin Version: 4.2.2, Gradle version: 6.8.1是可以的。

jaywcjlove commented 2 years ago

@qilovehua 能给个好的解决方案不?原来是根据 react native 生成的版本保持一致的。

qilovehua commented 2 years ago

@jaywcjlove 我google了好久没有找到解决方法。

ouabing commented 2 years ago

勉强改了一个能用的,不知道有没有什么问题,我不是安卓开发,也不太了解 gradle 和 maven-publish。需要在低版本的 Gradle 上也测试一下。

--- a/node_modules/@uiw/react-native-alipay/android/build.gradle
+++ b/node_modules/@uiw/react-native-alipay/android/build.gradle
@@ -20,7 +20,7 @@ def safeExtGet(prop, fallback) {
 }

 apply plugin: 'com.android.library'
-apply plugin: 'maven'
+apply plugin: 'maven-publish'

 buildscript {
     // The Android Gradle plugin is only required when opening the android folder stand-alone.
@@ -38,9 +38,6 @@ buildscript {
     }
 }

-apply plugin: 'com.android.library'
-apply plugin: 'maven'
-
 android {
     compileSdkVersion safeExtGet('compileSdkVersion', DEFAULT_COMPILE_SDK_VERSION)
     buildToolsVersion safeExtGet('buildToolsVersion', DEFAULT_BUILD_TOOLS_VERSION)
@@ -79,51 +76,23 @@ dependencies {
     implementation fileTree(dir: "libs", include: ["*.aar"])
 }

-def configureReactNativePom(def pom) {
-    def packageJson = new groovy.json.JsonSlurper().parseText(file('../package.json').text)
-
-    pom.project {
-        name packageJson.title
-        artifactId packageJson.name
-        version = packageJson.version
-        group = "com.uiwjs.alipay"
-        description packageJson.description
-        url packageJson.repository.baseUrl
-
-        licenses {
-            license {
-                name packageJson.license
-                url packageJson.repository.baseUrl + '/blob/master/' + packageJson.licenseFilename
-                distribution 'repo'
-            }
-        }
-
-        developers {
-            developer {
-                id packageJson.author.username
-                name packageJson.author.name
-            }
-        }
-    }
-}
-
 afterEvaluate { project ->
     // some Gradle build hooks ref:
     // https://www.oreilly.com/library/view/gradle-beyond-the/9781449373801/ch03.html
-    task androidJavadoc(type: Javadoc) {
-        source = android.sourceSets.main.java.srcDirs
-        classpath += files(android.bootClasspath)
-        classpath += files(project.getConfigurations().getByName('compile').asList())
-        include '**/*.java'
-    }
-
-    task androidJavadocJar(type: Jar, dependsOn: androidJavadoc) {
-        classifier = 'javadoc'
-        from androidJavadoc.destinationDir
-    }

     task androidSourcesJar(type: Jar) {
-        classifier = 'sources'
+        archiveClassifier = 'sources'
         from android.sourceSets.main.java.srcDirs
         include '**/*.java'
     }
@@ -139,15 +108,14 @@ afterEvaluate { project ->

     artifacts {
         archives androidSourcesJar
-        archives androidJavadocJar
     }

-    task installArchives(type: Upload) {
-        configuration = configurations.archives
-        repositories.mavenDeployer {
-            // Deploy to react-native-event-bridge/maven, ready to publish to npm
-            repository url: "file://${projectDir}/../android/maven"
-            configureReactNativePom pom
+    publishing {
+        publications {
+            maven(MavenPublication) {
+                artifact androidSourcesJar
+            }
         }
     }
 }
qilovehua commented 2 years ago

apply plugin: 'maven-publish' 只能在7.0.0+上使用的