当前位置: 首页 > 面试题库 >

React Native:错误:资源android:style / TextAppearance.Material.Widget.Button.Borderless.Colored未找到

王旺
2023-03-14
问题内容

我试图为我的React Native Android项目获取Facebook登录名,当我尝试使用react-native run-
android构建它时,出现此错误。

我最初以为这是我的Gradle版本的问题,因为React Native随附安装了Gradle 2.14,而我后来又升级到了Gradle 4.4。

我多次浏览了Facebook安装指南,但仍然遇到此错误。我还对代码进行了三重检查,以确保我没有使用任何错误的font / 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,但在node_modules文件夹中react-native-
fbsdk的目标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之后,我还没有失败过。收视率



 类似资料:
  • 它显示找不到某些属性,如DialogComerRadius和fontVariation设置。

  • 在最近升级了我的android工作室后,我不能再构建我的项目了。 下面显示了我的gradle.build文件: 如有任何帮助,不胜感激。

  • 在这里输入图片描述 其他人说「androidx.core:core-ktx:」是问题所在,但我找不到对这个库的依赖

  • 警告:不推荐使用属性,它对生成过程没有影响。/home/midhilaj/.gradle/caches/transforms-1/files-1.1/appcompat-v7-26.1.0.aar/be3106efb0df111fe5a3f7b356dd070b/res/values/values.xml错误:(246,5)错误:resource android:找不到attr/fontvaria

  • 我使用grails已经快一年了。从现在开始,我想在gsp中链接css或js文件。我做了以下几件事: > 我在web-app文件夹下创建了一个新文件(例如资源文件),并将所有文件夹放在那里(例如导入bootstrap时,我在资源下有一个父文件夹bootstrap,在bootstrap下有css、img和js文件夹及其文件)。 然后,为了导入一个css文件,我做了以下操作(以下是相关文档): 这非常有

  • 我收到以下错误: 错误:未找到可绘制的资源/abc_ic_ab_mtrl_am_。 错误:链接文件资源失败。 错误:java.util.concurrent.ExecutionException:java.util.concurrent.ExecutionException:com.android.tools.aapt2.Aapt2异常:AAPT2错误:检查日志以获取详细信息 错误:任务执行失败: