Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android的有人启动成功么 3.0.4 #258

Open
TallNutAlt opened this issue Sep 12, 2023 · 13 comments
Open

Android的有人启动成功么 3.0.4 #258

TallNutAlt opened this issue Sep 12, 2023 · 13 comments

Comments

@TallNutAlt
Copy link

rn 0.72.4
安装文档报错

@vfasky
Copy link

vfasky commented Sep 13, 2023

我折腾完了,rn 0.72.4 跑起来了, 下面是一些记录与 https://github.com/little-snow-fox/react-native-wechat-lib/blob/master/docs/build-setup-android.md 不一样的修改

在应用程序包和类中创建名为 "wxapi" 的包, 命名为 WXEntryActivity.javaWXPayEntryActivity.java

// WXEntryActivity.java
package com.mmf.business.wxapi;

import android.app.Activity;
import android.os.Bundle;
import com.wechatlib.WeChatLibModule;

public class WXEntryActivity extends Activity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        WeChatLibModule.handleIntent(getIntent());
        finish();
    }
}
// WXPayEntryActivity.java
package com.mmf.business.wxapi;

import android.app.Activity;
import android.os.Bundle;
import com.wechatlib.WeChatLibModule;

public class WXPayEntryActivity extends Activity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        WeChatLibModule.handleIntent(getIntent());
        finish();
    }
}

修改 android/build.gradle

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    ext {
        buildToolsVersion = "33.0.0"
        minSdkVersion = 23
        compileSdkVersion = 33
        targetSdkVersion = 33
        kotlin_version = '1.7.21'
        kotlinVersion = '1.7.21'
        // We use NDK 23 which has both M1 support and is the side-by-side NDK version from AGP.
        ndkVersion = "23.1.7779620"
    }
    repositories {
        google()
        mavenCentral()
    }
    dependencies {
        classpath("com.android.tools.build:gradle")
        classpath("com.facebook.react:react-native-gradle-plugin")
        classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version")
    }
}

allprojects {
    repositories {
        mavenCentral()
        google()

        maven {
            url 'https://maven.aliyun.com/nexus/content/repositories/releases/'
        }
        // 配置HMS Core SDK的Maven仓地址。
        maven {
            url 'https://developer.huawei.com/repo/'
        }
    }
}

android/gradle.properties 添加

android.disableAutomaticComponentCreation=true

android/app/build.gradle

在头部添加

apply plugin: "kotlin-android"

找到

android {
    ndkVersion rootProject.ext.ndkVersion

    compileSdkVersion rootProject.ext.compileSdkVersion
   
    // 添加下面 3 行 
    buildFeatures {
        viewBinding true
    }

@hhy123540
Copy link

我折腾完了,rn 0.72.4 跑起来了, 下面是一些记录与 https://github.com/little-snow-fox/react-native-wechat-lib/blob/master/docs/build-setup-android.md 不一样的修改

在应用程序包和类中创建名为 "wxapi" 的包, 命名为 WXEntryActivity.javaWXPayEntryActivity.java

// WXEntryActivity.java
package com.mmf.business.wxapi;

import android.app.Activity;
import android.os.Bundle;
import com.wechatlib.WeChatLibModule;

public class WXEntryActivity extends Activity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        WeChatLibModule.handleIntent(getIntent());
        finish();
    }
}
// WXPayEntryActivity.java
package com.mmf.business.wxapi;

import android.app.Activity;
import android.os.Bundle;
import com.wechatlib.WeChatLibModule;

public class WXPayEntryActivity extends Activity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        WeChatLibModule.handleIntent(getIntent());
        finish();
    }
}

修改 android/build.gradle

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    ext {
        buildToolsVersion = "33.0.0"
        minSdkVersion = 23
        compileSdkVersion = 33
        targetSdkVersion = 33
        kotlin_version = '1.7.21'
        kotlinVersion = '1.7.21'
        // We use NDK 23 which has both M1 support and is the side-by-side NDK version from AGP.
        ndkVersion = "23.1.7779620"
    }
    repositories {
        google()
        mavenCentral()
    }
    dependencies {
        classpath("com.android.tools.build:gradle")
        classpath("com.facebook.react:react-native-gradle-plugin")
        classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version")
    }
}

allprojects {
    repositories {
        mavenCentral()
        google()

        maven {
            url 'https://maven.aliyun.com/nexus/content/repositories/releases/'
        }
        // 配置HMS Core SDK的Maven仓地址。
        maven {
            url 'https://developer.huawei.com/repo/'
        }
    }
}

android/gradle.properties 添加

android.disableAutomaticComponentCreation=true

android/app/build.gradle

在头部添加

apply plugin: "kotlin-android"

找到

android {
    ndkVersion rootProject.ext.ndkVersion

    compileSdkVersion rootProject.ext.compileSdkVersion
   
    // 添加下面 3 行 
    buildFeatures {
        viewBinding true
    }

您好大佬 我是0.63的版本 使用的是react-native-wechat-lib1.1.27版本,但是在集合微信登录功能的适合,配置wxapi文件的时候,安卓运行报错了(import com.wechatlib.WeChatLibModule;),请问一下大佬有解决方案吗 @vfasky @little-snow-fox

@TallNutAlt TallNutAlt reopened this Oct 9, 2023
@TallNutAlt
Copy link
Author

TallNutAlt commented Oct 9, 2023

@hhy123540 可以看一下安卓包的目录是否有com.wechatlib.WeChatLibModule

@hhy123540
Copy link

@hhy123540 可以看一下安卓包的目录是否有com.wechatlib.WeChatLibModule

感谢大佬回复,我的安卓包目录里面没有com.wechatlib.WeChatLibModule。

@hhy123540
Copy link

@hhy123540 可以看一下安卓包的目录是否有com.wechatlib.WeChatLibModule

但是我把作者案例里面的com.wechatlib.WeChatLibModule copy进去 修改了包地址,也是一样报错了,所以我在想我是不是没有加文档里面没有写到的步骤

@TallNutAlt
Copy link
Author

@hhy123540 看作者安卓包目录里com/theweflex/react是否拥有,不需要去copy 看目录进行引入,文档可能有些错误

@hhy123540
Copy link

@hhy123540 看作者安卓包目录里com/theweflex/react是否拥有,不需要去copy 看目录进行引入,文档可能有些错误

好的大佬 我按您说的把WXEntryActivit的WeChatLibModule引入改成了import com.theweflex.react.WeChatLibModule; 还是出现了这个错误
6c13ad2a0d1e47d26c96018bbb7cd55

@TallNutAlt
Copy link
Author

@hhy123540 你看node_modules找到你下载的包去看安卓目录下的这个文件在哪,是否react link

@hhy123540
Copy link

@hhy123540 你看node_modules找到你下载的包去看安卓目录下的这个文件在哪,是否react link

您好大佬!我的rn版本是0.63,已经自动link了
按照您说的我也查阅了我的node_modules文件发现什么问题
image
然后我按照文档配置,运行android命令还是报错了:
image

@TallNutAlt
Copy link
Author

@hhy123540 这个我就不太清楚了,没有尝试过1.x的

@hhy123540
Copy link

@hhy123540 这个我就不太清楚了,没有尝试过1.x的

好的 感谢大佬回复!!!

@TingC92233
Copy link

有人在build的时候一直报这个错吗?"react-native": "0.71.3",
用的是项目中的example文件夹下的例子跑的
image

@qilovehua
Copy link

大佬微信支付回调正常吗?升级到RN0.72.10回调.then和.catch不执行了
WeChat.pay({ // appid: weChatPayOrder.appid, partnerId: weChatPayOrder.partnerid, prepayId: weChatPayOrder.prepayid, nonceStr: weChatPayOrder.noncestr, timeStamp: weChatPayOrder.timestamp, package: weChatPayOrder.package, sign: weChatPayOrder.sign, }) .then(res => {}) .catch(res => {})

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants