无法从Android Studio构建react-native,Build失败(cannot build react-native from Android Studio, Build failed)
安装react-native-fcm后,构建不成功。 我不太确定要更改哪些内容以及我用于Google服务的版本。
我的项目grandle文件如下所示:
// Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { repositories { jcenter() google() } dependencies { classpath 'com.android.tools.build:gradle:3.0.1' classpath 'com.google.gms:google-services:3.1.1' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files } } allprojects { repositories { mavenLocal() jcenter() maven { // Point to local maven repository url "$rootDir/../.expo-source/android/maven" } maven { url "https://jitpack.io" } maven { url "https://maven.google.com" } } } task clean(type: Delete) { delete rootProject.buildDir }
和我的项目/应用程序/ grandle看起来像:
apply plugin: 'com.android.application' android { compileSdkVersion 26 buildToolsVersion '26.0.2' defaultConfig { applicationId "fi.rogerstudio.possis" minSdkVersion 19 targetSdkVersion 26 versionCode 2 versionName "1.0.2" multiDexEnabled true ndk { abiFilters 'armeabi-v7a', 'x86' } manifestPlaceholders = [ 'appAuthRedirectScheme': 'fi.rogerstudio.possis' ] } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } dexOptions { javaMaxHeapSize "8g" } lintOptions { abortOnError false } } task exponentPrebuildStep(type: Exec) { workingDir '../../' if (System.getProperty('os.name').toLowerCase().contains('windows')) { commandLine 'cmd', '/c', '.\\.expo-source\\android\\detach-scripts\\prepare-detached-build.bat' } else { commandLine './.expo-source/android/detach-scripts/prepare-detached-build.sh' } } preBuild.dependsOn exponentPrebuildStep repositories{ flatDir{ dirs "../../node_modules/react-native-background-geolocation/android/libs" } mavenLocal() maven { url 'https://maven.fabric.io/public' } } dependencies { compile(project(':react-native-firebase')) { transitive = false } compile project(':react-native-vector-icons') compile fileTree(dir: 'libs', include: ['*.jar']) testCompile 'junit:junit:4.12' compile 'com.android.support:multidex:1.0.2' compile 'com.google.android.gms:play-services:11.6.2' compile 'com.google.android.gms:play-services-location:11.6.2' compile 'com.google.android.gms:play-services-places:11.6.2' compile 'com.google.android.gms:play-services-maps:11.6.2' compile 'com.google.android.gms:play-services-ads:11.6.2' compile('host.exp.exponent:expoview:22.0.0@aar') { exclude group: 'com.facebook.android', module: 'facebook-android-sdk' exclude group: 'com.facebook.android', module: 'audience-network-sdk' exclude group: 'io.nlopez.smartlocation', module: 'library' transitive = true } compile ('com.facebook.android:facebook-android-sdk:4.+') compile('com.facebook.android:audience-network-sdk:4.+') { exclude module: 'play-services-ads' } compile('io.nlopez.smartlocation:library:3.2.11') { transitive = false } compile(project(':react-native-background-geolocation')) { exclude group: 'com.google.android.gms', module: 'play-services-location' } compile(name: 'tslocationmanager', ext: 'aar') { exclude group: 'com.google.android.gms' } compile "com.google.firebase:firebase-messaging:11.6.2" } apply plugin: 'com.google.gms.google-services'
我得到的错误是:
Error:Execution failed for task app:processDebugGoogleServices'. Please fix the version conflict either by updating the version of the google-services plugin (information about the latest version is available at https://bintray.com/android/android-tools/com.google.gms.google-services/) or updating the version of com.google.android.gms to 11.6.2.
我找不到解决这个问题的方法
After installing react-native-fcm , the build does not succeed. I am not quite sure what to change and what version do I use for google services.
My project grandle file looks as below:
// Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { repositories { jcenter() google() } dependencies { classpath 'com.android.tools.build:gradle:3.0.1' classpath 'com.google.gms:google-services:3.1.1' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files } } allprojects { repositories { mavenLocal() jcenter() maven { // Point to local maven repository url "$rootDir/../.expo-source/android/maven" } maven { url "https://jitpack.io" } maven { url "https://maven.google.com" } } } task clean(type: Delete) { delete rootProject.buildDir }
and my project/app/grandle looks like:
apply plugin: 'com.android.application' android { compileSdkVersion 26 buildToolsVersion '26.0.2' defaultConfig { applicationId "fi.rogerstudio.possis" minSdkVersion 19 targetSdkVersion 26 versionCode 2 versionName "1.0.2" multiDexEnabled true ndk { abiFilters 'armeabi-v7a', 'x86' } manifestPlaceholders = [ 'appAuthRedirectScheme': 'fi.rogerstudio.possis' ] } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } dexOptions { javaMaxHeapSize "8g" } lintOptions { abortOnError false } } task exponentPrebuildStep(type: Exec) { workingDir '../../' if (System.getProperty('os.name').toLowerCase().contains('windows')) { commandLine 'cmd', '/c', '.\\.expo-source\\android\\detach-scripts\\prepare-detached-build.bat' } else { commandLine './.expo-source/android/detach-scripts/prepare-detached-build.sh' } } preBuild.dependsOn exponentPrebuildStep repositories{ flatDir{ dirs "../../node_modules/react-native-background-geolocation/android/libs" } mavenLocal() maven { url 'https://maven.fabric.io/public' } } dependencies { compile(project(':react-native-firebase')) { transitive = false } compile project(':react-native-vector-icons') compile fileTree(dir: 'libs', include: ['*.jar']) testCompile 'junit:junit:4.12' compile 'com.android.support:multidex:1.0.2' compile 'com.google.android.gms:play-services:11.6.2' compile 'com.google.android.gms:play-services-location:11.6.2' compile 'com.google.android.gms:play-services-places:11.6.2' compile 'com.google.android.gms:play-services-maps:11.6.2' compile 'com.google.android.gms:play-services-ads:11.6.2' compile('host.exp.exponent:expoview:22.0.0@aar') { exclude group: 'com.facebook.android', module: 'facebook-android-sdk' exclude group: 'com.facebook.android', module: 'audience-network-sdk' exclude group: 'io.nlopez.smartlocation', module: 'library' transitive = true } compile ('com.facebook.android:facebook-android-sdk:4.+') compile('com.facebook.android:audience-network-sdk:4.+') { exclude module: 'play-services-ads' } compile('io.nlopez.smartlocation:library:3.2.11') { transitive = false } compile(project(':react-native-background-geolocation')) { exclude group: 'com.google.android.gms', module: 'play-services-location' } compile(name: 'tslocationmanager', ext: 'aar') { exclude group: 'com.google.android.gms' } compile "com.google.firebase:firebase-messaging:11.6.2" } apply plugin: 'com.google.gms.google-services'
The error I am getting is:
Error:Execution failed for task app:processDebugGoogleServices'. Please fix the version conflict either by updating the version of the google-services plugin (information about the latest version is available at https://bintray.com/android/android-tools/com.google.gms.google-services/) or updating the version of com.google.android.gms to 11.6.2.
I cannot find any way of how do I solve this issue...
原文:https://stackoverflow.com/questions/48406647
最满意答案
在您的onClick方法的主Activity中执行如下操作:
MyFragment myFragment = (MyFragment) getSupportFragmentManager().findFragmentById(R.id.fragment_container); if(myFragment != null && myFragment.isAdded(){ myFragment.myRecyclerView.notifyItemRemoved(); }
简要解释:像这样,您正在您的片段容器中检索片段的实例,空检查总是一种很好的做法,以确保您不会在某个NPE中最终出现,然后从片段实例访问您的回收器视图。
In your main Activity in your onClick method do something like:
MyFragment myFragment = (MyFragment) getSupportFragmentManager().findFragmentById(R.id.fragment_container); if(myFragment != null && myFragment.isAdded(){ myFragment.myRecyclerView.notifyItemRemoved(); }
Brief explanation: Like this you are retrieving the instance of your fragment inside your fragment container, a null check is always a good practice to insure you won't end up in some NPE, and then access your recycler view from your fragment instance.
相关问答
更多-
尝试这个... 请在添加值wallpaperList.clear();之前清除您的Arraylist wallpaperList.clear(); on onPreExecute()方法。 recyclerView.setAdapter(wallPaperAdapter); wallPaperAdapter.notifyDataSetChanged(); 每当您的ArrayList值更改时,使用notifyDataSetChanged(); 它会刷新您的Recylierview Try ...
-
搞定了,这是编辑过的代码: mAdapter = new MyClassAdapter(this, mDataset.size); mRecyclerView.setAdapter(mAdapter); mRecyclerview.setItemViewCacheSize(mDataset.size()); List
list = new ArrayList<>(); for (int i = 0; i < mDataset.size(); i++) { View ... -
添加FragmentTransaction以开始事务 Fragment fragment; fragment = new TodaysmemeFragement(); FragmentManager fragmentManager = getFragmentManager(); FragmentTransaction ft = fragmentManager.beginTransaction(); ft.addToBackStack(null); ft.replace(R.id.main_co ...
-
在您的onClick方法的主Activity中执行如下操作: MyFragment myFragment = (MyFragment) getSupportFragmentManager().findFragmentById(R.id.fragment_container); if(myFragment != null && myFragment.isAdded(){ myFragment.myRecyclerView.notifyItemRemoved(); } 简要解释:像这样,您正在您的片段 ...
-
好的,你需要更改以下内容:更新 - recyclerView.setLayoutManager(new LinearLayoutManager(this)); to recyclerView.setLayoutManager(new LinearLayoutManager(this,LinearLayoutManager.VERTICAL,false)); 并在适配器类更改: @Override public int getItemCount() { return data.size(); } 而已 ...
-
这是一个Scope Problem 。 您需要在某个类别成员中定义adapter 。 如果您希望片段A和片段D中呈现的数据不同,请将adapter作为彼此的成员,然后在每个Fragment.onCreate()初始化。 所以它不会重新创建适配器外部时间。 (确保ViewPager有足够的缓存号,否则它将重新创建整个非缓存的片段) 如果您希望FragmentA和FragmentD显示相同的数据或部分相同的数据,请在MainActivity.onCreate创建adapter ,并将其作为参数传递给Fragme ...
-
从菜单更新RecyclerView(Update RecyclerView from menu)[2023-11-23]
在适配器中实现一个reset()所有项目标记为“未完成”的reset()方法,然后尝试: LessonsListFragment.rv.getAdapter().reset(); LessonsListFragment.rv.getAdapter().notifyDataSetChanged(); 代替: LessonsListFragment.rv.getAdapter().notifyItemRangeChanged(0, LessonsListFragment.rv.getAdapter().get ... -
哪里声明了适配器变量? 据我所知,它被声明为片段中的实例变量,而MainActivity是另一个类。 在这种情况下,您应该能够直接使用它: adapter.getFilter().filter(cs); Where adapter variable is declared? As far as I understood it is declared as an instance variable within your fragment, while MainActivity is another clas ...
-
问题在于这一行。 recyclerView = getActivity().findViewById(R.id.recyclerview1); 用这个替换那条线 recyclerView = v.findViewById(R.id.recyclerview1); 您应该从您的方法开始时初始化的片段布局中获取回收器视图,而不是从活动中获取 The problem is on this line. recyclerView = getActivity().findViewById(R.id.recycler ...
-
谢谢你们的答案,我解决了问题,使用带有String值的接口将适配器连接到包含recyclerview的片段,这里的另一个片段就是我所做的:这是接口 public interface FragmentCommunication { void respond(int position,String name,String job); } 这是适配器 public class RecyclerAdapter extends RecyclerView.Adapter
相关文章
更多- redhat6.4上build storm 0.9.0.1
- Nutch 1-build
- 【Hadoop】Build and Run HDFS
- 重新Build Hadoop后进入Hive客户端异常
- zoj 2966 Build The Electric System
- Professional Android 4 Application Development
- Android 使用隐藏API 开发应用程序
- Android开发_微信分享功能
- Android微信分享功能实例+demo
- 微信Android接入指南
最新问答
更多- 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
- 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
- OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
- 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
- codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
- 在计算机拍照在哪里进入
- 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
- No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
- 单页应用程序:页面重新加载(Single Page Application: page reload)
- 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
- System.StackOverflow错误(System.StackOverflow error)
- KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
- 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
- android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
- TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
- 企业安全培训的各项内容
- 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
- C#类名中允许哪些字符?(What characters are allowed in C# class name?)
- NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
- 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
- 将多个行和可变行移动到列(moving multiple and variable rows to columns)
- 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
- 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
- Angular $资源不会改变方法(Angular $resource doesn't change method)
- 在Angular 5中不是一个函数(is not a function in Angular 5)
- 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
- 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
- 常见的python rpc和cli接口(Common python rpc and cli interface)
- Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
- 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)