RxReader / tencent_kit

Flutter版QQ登录/分享
MIT License
235 stars 63 forks source link

Android 端编译失败(androidx问题) #9

Closed ylytddd closed 4 years ago

ylytddd commented 4 years ago

tencent.login(registrar.activity(), scope, loginListener); ^ 找不到androidx.fragment.app.Fragment的类文件

今天重新安装了flutter, 编译突然报错. 不知道如何解决?

droplet-js commented 4 years ago

请看 AndroidX 分支

ylytddd commented 4 years ago

是怎么使用呢? 根据你的修改记录去一个个修改吗?

limhGeek commented 4 years ago

fake_tencent-0.3.3\android\src\main\java\io\github\v7lin\faketencent\FakeTencentPlugin.java:154: ����: �޷�����Fragment tencent.login(registrar.activity(), scope, loginListener); ################ 请问AndroidX版本用哪个?我用0.3.3还是报这个

limhGeek commented 4 years ago

在AndroidStudio里运行报:找不到androidx.fragment.app.Fragment的类文件

droplet-js commented 4 years ago

工程是支持AndroidX和非AndroidX的 这原因应该是你们引用其他不支持AndroidX的库引发的,贴上完整的日志和pubspec吧,有空的话就帮你们分析一下吧。

limhGeek commented 4 years ago

我把这个库移除引用不报错了,加上就不行了,我主工程已经迁移到AndroidX了

droplet-js commented 4 years ago

晚上我再看看吧,我目前AndroidX工程使用这个插件是任何没问题的

sunshinewei commented 4 years ago

D:\flutter_SDk\flutter.pub-cache\hosted\pub.flutter-io.cn\fake_tencent-0.3.3\android\src\main\java\io\github\v7lin\faketencent\FakeTencentPlugin.java:154: ����: �޷�����Fragment tencent.login(registrar.activity(), scope, loginListener); ^ �Ҳ���androidx.fragment.app.Fragment�����ļ� ע: D:\flutter_SDk\flutter.pub-cache\hosted\pub.flutter-io.cn\fake_tencent-0.3.3\android\src\main\java\io\github\v7lin\faketencent\FakeTencentPlugin.javaʹ�û򸲸����ѹ�ʱ�� API�� ע: �й���ϸ��Ϣ, ��ʹ�� -Xlint:deprecation ���±��롣 1 ������


The Gradle failure may have been because of AndroidX incompatibilities in this Flutter app. See https://goo.gl/CP92wY for more information on the problem and how to fix it.


sunshinewei commented 4 years ago

报这个错误

droplet-js commented 4 years ago

提供一下Demo吧

droplet-js commented 4 years ago

有一个问题,你们是怎么升级AndroidX的?看了官方指导了吗?

ylytddd commented 4 years ago

有一个问题,你们是怎么升级AndroidX的?看了官方指导了吗?

额..倒是没有特地的升级, 就是按你的AndroidX分支的改动, 一个个对照着改

limhGeek commented 4 years ago

有一个问题,你们是怎么升级AndroidX的?看了官方指导了吗?

设置这两个值: android.enableJetifier=true android.useAndroidX=true ######## compileSdkVersion 28 ######## classpath 'com.android.tools.build:gradle:3.4.2' distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip ######## 然后工具栏:Refactor-->Migrate to AndroidX

droplet-js commented 4 years ago

… 先去官网上找升级指南吧 …

ylytddd commented 4 years ago

… 先去官网上找升级指南吧 …

我安装flutter官网的指南改的, 发现按你的AndroidX分支的改动, 一个个对照着改 是差不多的. 应该是迁移完成了吧. 还是报相同的错误.

另外master分支已经是适配AndroidX的了吧?

droplet-js commented 4 years ago

其他插件呢,比如说官方插件

ylytddd commented 4 years ago

其他插件呢,比如说官方插件

Flutter列出来的几个包, 我试了其中4个, 有些会报错

报错信息都是 程序包android.support.annotation不存在 我把这两个插件升级到最新版本就都正常了

你看这样能分析出来什么问题吗?

droplet-js commented 4 years ago

帮你以正确姿势升级Android而已,fake-tencent库本身并没有问题。

sunshinewei commented 4 years ago

tencent.login(registrar.activity(), scope, loginListener); ^ 找不到androidx.fragment.app.Fragment的类文件

今天重新安装了flutter, 编译突然报错. 不知道如何解决?

在android工程中把缺少的内库添加进去,如api 'com.android.support:support-v4:28.0.0'。就可以解决了。

droplet-js commented 4 years ago

io.github.v7lin:tencent-android:3.3.3+2

这个库已经依赖 support-v4 了,请检查一下你的其他插件是否有依赖 support-v4 的低版本 …

droplet-js commented 4 years ago

不懂排除,可用以下方式解决

./android/build.gradle

...
apply from: 'build_compat.gradle'

./android/build_compat.gradle

/**
 * 编译环境统一
 */

project.subprojects { p ->
    p.afterEvaluate {
        if (p.hasProperty('android')) {
            generateBuildConfigurations p.android
            generateSupportConfigurations p
        }
    }
}

// 保持android编译版本一致
void generateBuildConfigurations(def android) {
    android.compileSdkVersion = 28
}

// 保持support依赖版本一致
void generateSupportConfigurations(def p) {
    // System.out.println(p)
    def supportVersion = '28.0.0'

    def implementationConfig = p.configurations.implementation
    def implementationSupportDependencies = []

    implementationConfig.dependencies.each { d ->
        // System.out.println("implementation - $d.group:$d.name:$d.version")
        if (d.group == 'com.android.support' && d.version != supportVersion) {
            implementationSupportDependencies.add(d)
        }
    }

    implementationConfig.dependencies.removeAll(implementationSupportDependencies)
    implementationSupportDependencies.each { d ->
        p.dependencies.add('implementation', "$d.group:$d.name:$supportVersion")
    }

    def apiConfig = p.configurations.api
    def apiSupportDependencies = []

    apiConfig.dependencies.each { d ->
        // System.out.println("api - $d.group:$d.name:$d.version")
        if (d.group == 'com.android.support' && d.version != supportVersion) {
            apiSupportDependencies.add(d)
        }
    }

    apiConfig.dependencies.removeAll(apiSupportDependencies)
    apiSupportDependencies.each { d ->
        p.dependencies.add('api', "$d.group:$d.name:$supportVersion")
    }
}
AlanGrey commented 4 years ago

帮你以正确姿势升级Android而已,fake-tencent库本身并没有问题。

我这边也又这个问题,能不能贴一个你运行成功的Flutter版本? 我检查了项目其他插件都是androidX的,也按照Migrate to AndroidX方法,更新了项目。还是报错!

ע: C:\Users\grey\AppData\Roaming\Pub\Cache\git\fake_tencent-db5a7b5d6c2c681ec160be3de40268548890bae0\android\src\main\java\io\github\v7lin\faketencent\FakeTencentPlugin.javaʹ�û򸲸����ѹ�ʱ�� API�� ע: �й���ϸ��Ϣ, ��ʹ�� -Xlint:deprecation ���±��롣 1 ������

droplet-js commented 4 years ago

1.5.4—1.7.8都正常

AlanGrey commented 4 years ago

1.5.4—1.7.8都正常

感觉,我没有拉到androidX的那个版本下拉,我尝试一下直接clone那个可以的分支。不行的话,在Fork

AlanGrey commented 4 years ago

尝试很多方法, 校对其他库的冲突。发现其实不一定是androidX的问题,在android项目Rebulid project的时候,它就是提示找不到androidX.fragment.app.fragment的类,也就是说你的项目没有应用到该库,或者其他的原因该库没引用进去。

需要在fake_tencent项目build.gradle里添加 com.android.support:support-v4:28.0.0就可以了; (麻烦,看一下;在更新个小分支,哈。)

droplet-js commented 4 years ago

前些天升级Gradle复现了该问题,已确认是Gradle版本兼容问题,在Gradle 3.3.0上就不会存在这个问题,最近没啥空,后续有空就解决一下。

droplet-js commented 4 years ago

fix 0.3.4