gpt4 book ai didi

android - React Native : error: resource android:style/TextAppearance. Material.Widget.Button.Borderless.Colored 未找到

转载 作者:塔克拉玛干 更新时间:2023-11-02 07:53:15 35 4
gpt4 key购买 nike

我正在尝试为我的 React Native Android 项目获取 Facebook 登录,当我尝试使用 react-native run-android 构建它时,我收到了这个错误。

一开始我以为是我的 Gradle 版本有问题,因为 React Native 是安装了 Gradle 2.14,后来我升级到了 Gradle 4.4。

我多次返回 Facebook 安装指南,但仍然收到此错误。我还三次检查了我的代码,以确保我没有使用任何错误的字体/fontWeight/fontStyle。我唯一能想到的是来自标准组件的 Facebook 按钮有不受支持的样式吗?我不确定。

如有任何帮助,我们将不胜感激。我做这件事的时间比我想承认的要长!

MainActivity.java文件

package com.myproj;

import android.content.Intent;
import com.facebook.react.ReactActivity;
import com.facebook.reactnative.androidsdk.FBSDKPackage;
import com.facebook.FacebookSdk;

public class MainActivity extends ReactActivity {

/**
* Returns the name of the main component registered from JavaScript.
* This is used to schedule rendering of the component.
*/
@Override
protected String getMainComponentName() {
return "myproj";
}

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
MainApplication.getCallbackManager().onActivityResult(requestCode, resultCode, data);
}
}

MainApplication.java 文件

package com.myproj;

import android.app.Application;

import com.facebook.react.ReactApplication;
import com.facebook.reactnative.androidsdk.FBSDKPackage;
import com.facebook.reactnative.androidsdk.FBSDKPackage;
import com.facebook.react.ReactNativeHost;
import com.facebook.react.ReactPackage;
import com.facebook.react.shell.MainReactPackage;
import com.facebook.soloader.SoLoader;
import com.facebook.CallbackManager;
import com.facebook.FacebookSdk;
import com.facebook.appevents.AppEventsLogger;





import java.util.Arrays;
import java.util.List;

public class MainApplication extends Application implements ReactApplication {

private static CallbackManager mCallbackManager = CallbackManager.Factory.create();

protected static CallbackManager getCallbackManager() {
return mCallbackManager;
}

private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {
@Override
public boolean getUseDeveloperSupport() {
return BuildConfig.DEBUG;
}


@Override
protected List<ReactPackage> getPackages() {
return Arrays.<ReactPackage>asList(
new MainReactPackage(),
new FBSDKPackage(mCallbackManager)
);
}

@Override
protected String getJSMainModuleName() {
return "index";
}
};

@Override
public ReactNativeHost getReactNativeHost() {
return mReactNativeHost;
}

@Override
public void onCreate() {
super.onCreate();
AppEventsLogger.activateApp(this);

}

}

myProj/android/build.gradle 文件

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



buildscript {
repositories {
jcenter()


}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.0'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}

allprojects {
repositories {
mavenLocal()
jcenter()
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url "$rootDir/../node_modules/react-native/android"
}

}
}

我得到的错误:

> Configure project :app 
WARNING: Configuration 'compile' is obsolete and has been replaced with 'implementation'.
It will be removed at the end of 2018

> Configure project :react-native-fbsdk
WARNING: Configuration 'compile' is obsolete and has been replaced with 'implementation'.
It will be removed at the end of 2018
WARNING: The specified Android SDK Build Tools version (26.0.2) is ignored, as it is below the minimum supported version (27.0.3) for Android Gradle Plugin 3.1.0.
Android SDK Build Tools 27.0.3 will be used.
To suppress this warning, remove "buildToolsVersion '26.0.2'" from your build.gradle file, as each version of the Android Gradle Plugin now has a default version of the build tools.

error: resource android:style/TextAppearance.Material.Widget.Button.Borderless.Colored not found.
error: resource android:style/TextAppearance.Material.Widget.Button.Colored not found.
/Users/me/.gradle/caches/transforms-1/files-1.1/appcompat-v7-27.0.2.aar/a1a4a045a3ea2f70ae16170c81e2001d/res/values-v26/values-v26.xml:9:5-12:13: AAPT: error: resource android:attr/colorError not found.

/Users/me/.gradle/caches/transforms-1/files-1.1/appcompat-v7-27.0.2.aar/a1a4a045a3ea2f70ae16170c81e2001d/res/values-v26/values-v26.xml:13:5-16:13: AAPT: error: resource android:attr/colorError not found.

/Users/me/.gradle/caches/transforms-1/files-1.1/appcompat-v7-27.0.2.aar/a1a4a045a3ea2f70ae16170c81e2001d/res/values-v26/values-v26.xml:17:5-93: AAPT: error: style attribute 'android:attr/keyboardNavigationCluster' not found.

/Users/me/.gradle/caches/transforms-1/files-1.1/appcompat-v7-27.0.2.aar/a1a4a045a3ea2f70ae16170c81e2001d/res/values/values.xml:252:5-69: AAPT: error: resource android:attr/fontStyle not found.

/Users/me/.gradle/caches/transforms-1/files-1.1/appcompat-v7-27.0.2.aar/a1a4a045a3ea2f70ae16170c81e2001d/res/values/values.xml:252:5-69: AAPT: error: resource android:attr/font not found.

/Users/me/.gradle/caches/transforms-1/files-1.1/appcompat-v7-27.0.2.aar/a1a4a045a3ea2f70ae16170c81e2001d/res/values/values.xml:252:5-69: AAPT: error: resource android:attr/fontWeight not found.

error: failed linking references.

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:processDebugResources'.
> Failed to process resources, see aapt output above for details.

总的方面也很困惑——Facebook 在 RN 设置指南中告诉你目标 SDK 23 或 6.0 但是 react-native-fbsdk 的 node_modules 文件夹内的目标 SDK 更高因此给我警告

最佳答案

不记得我是从哪里学来的,但如果你觉得鲁莽,你可以通过添加将库强制到同一个 sdk 上:

subprojects {
afterEvaluate {project ->
// force libs to use recent buildtools
if (project.hasProperty("android")) {
android {
compileSdkVersion = 27 // change to match your desired version
buildToolsVersion = "27.0.3" // ....
}
}
}
}

到你的根 android/build.gradle。在 react-native-git-upgrade 之后,到目前为止还没有让我失望。嗯嗯

关于android - React Native : error: resource android:style/TextAppearance. Material.Widget.Button.Borderless.Colored 未找到,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50574492/

35 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com