使用带有gradle插件版本的Android Studio 3.3 Canary 11 3.3.0-alpha11.尝试同步gradle时,它会引发以下错误
WARNING: API 'variant.getExternalNativeBuildTasks()' is obsolete and has been
replaced with 'variant.getExternalNativeBuildProviders()'.
It will be removed at the end of 2019.
For more information, see https://d.android.com/r/tools/task-configuration-
avoidance
Affected Modules: app
Run Code Online (Sandbox Code Playgroud)
单击错误会将我引导至gradle文件中的此行
applicationVariants.all { variant ->
variant.outputs.all {
outputFileName = "${variant.name}-${variant.versionName}.apk"
}
}
Run Code Online (Sandbox Code Playgroud)
我到底需要改变什么?
项目 build.gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
mavenCentral() // jcenter() works as well because it pulls from …Run Code Online (Sandbox Code Playgroud) android firebase android-studio android-gradle-plugin fabric.io
我已经检查了我的app build.gradle文件,这些是与firebase相关的唯一行
/***
* Firebase
*/
implementation 'com.google.firebase:firebase-core:15.0.0'
implementation 'com.google.firebase:firebase-messaging:15.0.0'
implementation('com.crashlytics.sdk.android:crashlytics:2.9.1@aar') {
transitive = true
}
implementation 'com.google.firebase:firebase-ads:15.0.0'
Run Code Online (Sandbox Code Playgroud)
我没有任何使用firebase的库,所以我认为使用旧版本的库不会出现问题.
问题是我不能使用新的v15版本的firebase构建gradle,clean项目或重建项目,因为它不断抛出错误 All firebase libraries must be either above or below 14.0.0
android firebase firebase-cloud-messaging firebase-analytics firebase-crash-reporting
尝试通过Android Studio 3.4 Canary 1运行apk时收到错误消息。
Gradle插件版本 com.android.tools.build:gradle:3.4.0-alpha01
Installation failed with message Failed to commit install session 526049657 with command cmd package install-commit 526049657.. It is possible that this issue is resolved by uninstalling an existing version of the apk if it is present, and then re-installing.
Run Code Online (Sandbox Code Playgroud)
我试过卸载apk,重新启动android studio和设备,并使缓存无效并重建,但似乎没有任何效果。
我正在尝试使用GcmTaskService实现服务.这是我在调用名为Myservice的服务的主要活动中的代码.
OneoffTask myTask = new OneoffTask.Builder()
.setService(MyService.class)
.setExecutionWindow(0, 10)
.setTag("test-upload")
.build();
GcmNetworkManager.getInstance(this).schedule(myTask);
Run Code Online (Sandbox Code Playgroud)
这是MyService类.
public class MyService extends GcmTaskService {
@Override
public int onRunTask(TaskParams taskParams) {
Log.i("onRunTask: ", taskParams.getTag() + "");
return GcmNetworkManager.RESULT_RESCHEDULE;
}
}
Run Code Online (Sandbox Code Playgroud)
我想知道的是如何将参数传递给此服务?
我最近将我的项目更新到Android支持库23.1,我的代码的这部分现在给出了错误.
它在更新之前工作并且评论只是这部分允许我运行应用程序罚款.究竟是错误还是有变化?
Glide.with(getApplicationContext())
.load(R.drawable.banner)
.fitCenter()
.override(width, height / 2)
.diskCacheStrategy(DiskCacheStrategy.RESULT)
.into(back);
if (picture != null) {
Glide.with(getApplicationContext())
.load(picture)
.fitCenter()
.override(width / 2, height / 2)
.into(profile);
} else {
Glide.with(getApplicationContext())
.load(R.drawable.profile_p)
.fitCenter()
.override(width / 2, height / 2)
.into(profile);
}
Run Code Online (Sandbox Code Playgroud)
这是错误日志.
10-16 22:41:27.238 16313-16313/atsystems.cal E/AndroidRuntime: FATAL EXCEPTION: main
10-16 22:41:27.238 16313-16313/atsystems.cal E/AndroidRuntime: Process: atsystems.cal, PID: 16313
10-16 22:41:27.238 16313-16313/atsystems.cal E/AndroidRuntime: java.lang.RuntimeException: Unable to start activity ComponentInfo{atsystems.cal/atsystems.cal.MainActivity}: java.lang.IllegalArgumentException: You must pass in a non null View
10-16 22:41:27.238 16313-16313/atsystems.cal E/AndroidRuntime: at …Run Code Online (Sandbox Code Playgroud) 我有一个父组件,它是一个包含 header 的平面列表HeaderComponent。这HeaderComponent是我创建的一个自定义组件,它包含 2 个自己的子组件。每当我刷新列表时,我都会将一个布尔值传递给HeaderComponent传递给它自己的孩子的as 道具,我这样做是为了检查每个组件是否需要获取新数据。问题是每当父组件刷新并设置新状态时,子组件的构造函数每次都会被调用。不应该只在父级第一次初始化时调用构造函数,然后所有进一步的调用都涉及调用子级的 shouldComponentUpdate 方法,以查看它是否需要更新。
父组件
_renderHeader = () => {
return <HeaderComponent Items={this.state.Data} refresh={this.state.refresh}/>;
};
render() {
console.log("TAG_RENDER render called " + this.state.refresh);
return (
<FlatList
refreshing={this.state.refresh}
onRefresh={() => {
console.log("onRefresh");
this.setState({
refresh: true
}, () => {
this._fetchData();
});
}}
......
ListHeaderComponent={() => this._renderHeader()}
.......
/>
);
}
Run Code Online (Sandbox Code Playgroud)
标题组件
export default class HeaderComponent extends React.Component {
constructor(props) {
super(props);
console.debug("HeaderComponent");
}
render() {
return (
<MainHeader Items={this.props.Items}/>
<SubHeader refresh={this.props.refresh}/> …Run Code Online (Sandbox Code Playgroud) 我已经将 FCM 与旧协议一起使用,但找不到任何具体的文档来将新的 FCM HTTP v1 API 与 php 结合使用。
我已设法将Google API 客户端库导入到我的项目中,但找不到有关如何获取 fcm 消息所需范围的访问令牌的任何文档或教程。
我state用来存储以下数据。
state = {
refresh: true,
isFetching: true,
showLoadingBottom: false,
data: []
};
Run Code Online (Sandbox Code Playgroud)
在componentDidMount我手动调用一个_fetchData将数据加载到this.state.data.
当 flatlist 滚动到最后时,它会触发_fetchData两次,最终两次返回相同的数据(这是另一个问题,为什么它会触发两次?)。
一旦 flatlist 到达末尾,即没有更多数据从服务器返回,它就会进入一个无限循环,因为onEndReached即使服务器没有返回新数据并this.state.data保持不变,它也会一遍又一遍地不断触发。
这是我的render代码
render() {
return (
<View
style={{
flex: 1
}}>
<FlatList
refreshControl={
<RefreshControl
refreshing={this.state.refresh}
onRefresh={() => {
this.setState({
refresh: true
}, this._fetchData);
}}
title={"Pull To Refresh"}
tintColor={darkGrey}
titleColor={darkGrey}/>
}
onEndReachedThreshold={0.5}
onEndReached={() => {
this.setState({
showLoadingBottom: true
}, () => {
this._fetchData();
});
}}
showsVerticalScrollIndicator={false} …Run Code Online (Sandbox Code Playgroud) reactjs react-native react-native-listview react-native-android react-native-flatlist
我有一个需要在活动上方显示的片段,但活动中的按钮一直显示在该片段上方。我需要该片段与活动完全重叠。
活动的xml。
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="@color/colorPrimary"
android:minHeight="?attr/actionBarSize"
app:navigationIcon="@drawable/ic_close_black_24dp"
app:popupTheme="@style/Theme.AppCompat.NoActionBar"
app:titleTextColor="@color/toolbarTextColor" />
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:layout_width="match_parent"
android:layout_height="match_parent"
android:inputType="textMultiLine"
android:lines="3"
android:maxLines="10"
android:scrollbars="vertical" />
</android.support.design.widget.TextInputLayout>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
片段
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="@color/colorPrimary"
android:minHeight="?attr/actionBarSize"
app:navigationIcon="@drawable/ic_close_black_24dp"
app:popupTheme="@style/Theme.AppCompat.NoActionBar"
app:titleTextColor="@color/toolbarTextColor" />
<TextView
android:id="@+id/firstnameTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="@dimen/activity_horizontal_margin"
/>
<TextView
android:id="@+id/lastnameTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="@dimen/activity_horizontal_margin"
/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Chat" />
<fragment
android:id="@+id/fragment_chat"
android:name="user.InitiateChat_Fragment"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</FrameLayout>
Run Code Online (Sandbox Code Playgroud)
private void init() { …Run Code Online (Sandbox Code Playgroud) xml android android-layout android-fragments android-fragmentactivity
如果我有一个扩展基本活动BA的活动A,那么我能够安全地从活动A访问活动BA中的任何变量.我现在使用的是包含片段F的活动A.现在从这个片段我想要以同样的方式访问A的所有变量,就像我上面所做的那样,如果没有,除了通过公共方法使其可用之外,还有一种安全的方法.
或者有没有办法可以将基本活动中的变量复制到基本片段,以便在所有活动和片段中都可用.
java android android-fragments android-activity android-fragmentactivity
android ×7
firebase ×3
react-native ×2
reactjs ×2
drawer ×1
ecmascript-6 ×1
fabric.io ×1
java ×1
javascript ×1
navigation ×1
parameters ×1
php ×1
react-props ×1
service ×1
view ×1
xml ×1