我正在开发 Flutter 应用程序,并在 logcat 中不断收到此错误字符串。
Failed assertion: boolean expression must not be null
Run Code Online (Sandbox Code Playgroud)
这是有问题的代码:
@override
Widget build(BuildContext context) {
return Center(
child: ListView(
children: <Widget>[
TextField(
controller: controller,
decoration: InputDecoration(
hintText: "Type in something..."
),
),
RaisedButton(
child: Text("Submit"),
onPressed: () => addString(),
),
Flex(
direction: Axis.vertical,
children: (list_two = null) ? [] :
list_two.map((String s) => Text(s)).toList()
)
],
),
);
}
Run Code Online (Sandbox Code Playgroud)
导致问题的原因是什么?
我花了最后48小时拉着我的头发试图找到这个问题的答案.提出此问题的人:如何为Google Places API制作API KEY? 我遇到了同样的问题,但从未得到答案.
基本上,我需要帮助获取Google PLACES api密钥.我已经有一个map api key,工作正常,但是我无法获得一个场所API密钥.我已经按照我能找到的每一个教程进行了包括(为一对夫妇命名:( http://wptrafficanalyzer.in/blog/showing-nearby-places-using-google-places-api-and-google-map-android-api -v2 /),(http://www.androidhive.info/2012/08/android-working-with-google-places-and-maps-tutorial/#),(https://www.youtube.com/看?v = 8PVK1Ue5rvk)但绝对没有任何效果.
我在下面添加了一些截图来说明问题:
1)

2)

3)

4)

我问过的每个人都告诉我,它只是位于https://console.developers.google.com网站的某个地方,但是看起来有两天看起来让我无处可去.有人可以帮我找到确切地点获取地方api吗?(同样,不是地图api,我已经有了这个,并且由于我没有辅助密钥而只得到REQUEST_DENIED错误.
在此先感谢所有人
-Silmarilos
我在Android应用中使用Firebase作为我们的消息服务.我已经对Firebase进行了相当多的研究,我理解无论应用程序是在前台运行还是现在运行都会改变onMessageReceived方法中收到的数据类型.
我想要完成的是解析来自Remotemessage的传入数据,并根据自定义标记执行与它不同的操作.IE,如果数据映射包含一个名为"My_Custom_Tag"的字段,我想完全覆盖弹出的标准firebase消息并编写一个自定义消息.
问题是,当应用程序在后台运行时,我放入onMessageReceived的任何代码都不会被触发.当应用程序在前台运行时,它可以正常工作,但如果应用程序在后台,则无法检测/接收任何内容.
以下是一些示例代码:
@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
super.onMessageReceived(remoteMessage);
Map<String, String> aMap = remoteMessage.getData();
//Custom object here for easier parsing
PushNotificationsPojo pojo = this.convertResponseToPojo(aMap);
if(pojo == null){
passToFirebase(remoteMessage);
return;
}
if(pojo.getData().getCustomTag().equals(PushNotificationsPojo.ID_TAG_CHAT_MESSAGE)) {
createCustomNotification1(pojo);
} else if (pojo.getData().getCustomTag().equals(PushNotificationsPojo.ID_TAG_SOME_OTHER_MESSAGE)){
createCustomNotification2(pojo);
} else if (pojo.getData().getCustomTag().equals(PushNotificationsPojo.ID_TAG_STUFF_AND_WHATNOT)) {
createCustomNotification3(pojo);
} else {
passToFirebase(remoteMessage);
}
}
Run Code Online (Sandbox Code Playgroud)
我的问题是,如何编辑MyFirebaseMessagingService以便我可以检查传入的数据,确定标记信息,并决定将其传递给firebase,以便它可以使用标准处理或不将其传递给firebase并编写我的我的应用程序在后台运行时,我自己的自定义显示通知?
谢谢大家!
按我以前问的问题,火力地堡onMessageReceived不叫当应用程序在后台,我需要的有效载荷更改为"数据"的有效载荷,而不是一个"通知"的有效载荷.(请参阅此处的链接 - Firebase推送通知和FCM消息之间有什么区别?).
问题是,无论是IOS和Android的应用程序,我们必须利用火力地堡和IOS应用程序需要推送通知有效载荷使用"通知"结构,而Android需要"数据"有效载荷结构.
因此,我的问题是,您如何区分通过firebase sdk获得的Android和IOS令牌/ ID?
如果我们的服务器保存这些ID并需要发送推送通知,则需要指定Android与IOS以更改有效负载结构.完成此识别的唯一方法是通过基于应用程序的服务调用来区分IOS和Android吗?或者是否有更复杂的方法使用Firebase,这将允许我们指出它是哪个设备?
谢谢大家.
我目前正在开发一个项目,我通过https调用将数据发送到我们的服务器api.项目的基本URL支持ssl(我们的url api端点以https:// api ....开头).我正在使用Retrofit 2和OkHttp3,我正在设置这样的客户端:
public static void buildClient(){
//Misc code here.... not showing for security reasons.
OkHttpClient client = RetrofitClient.configureClient(new OkHttpClient());
//I make calls here to update interceptors, timeouts, etc.
Retrofit retrofit = new Retrofit.Builder()
.baseUrl(BASE_URL)
.addConverterFactory(GsonConverterFactory.create(new Gson()))
.client(client)
.build();
}
//Setup the ssl stuff here
public static OkHttpClient configureClient(final OkHttpClient client) {
final TrustManager[] certs = new TrustManager[]{new X509TrustManager() {
@Override
public X509Certificate[] getAcceptedIssuers() {
return null;
}
@Override
public void checkServerTrusted(final X509Certificate[] chain,
final String …Run Code Online (Sandbox Code Playgroud) 在尝试编译此代码时:
import 'package:flutter/material.dart';
import 'package:startup_namer/misc/Constants.dart';
import 'package:startup_namer/ui/question_text.dart';
import '../utils/question.dart';
import '../utils/quiz.dart';
import '../ui/answer_button.dart';
import '../ui/correct_wrong_overlay.dart';
class QuizPage extends StatefulWidget {
@override
State createState() => new QuizPageState();
}
//States are mutable
class QuizPageState extends State<QuizPage> {
static List<Question> quizQuestions = [
new Question("5 * 5 = 25", true),
new Question("4 + 2 = 6", true),
new Question("4 + 2 = 7", false),
new Question("Computers don't use energy", false),
new Question("B is after A in the alphabet", false),
];
Question currentQuestion;
Quiz …Run Code Online (Sandbox Code Playgroud) 我正在开发一个项目,该项目需要将所有证书用于单个调用,每当我尝试设置 sslSocketFactory 时,我都会收到一个错误,指示 ExceptionInInitializerError。
我搜索了 SO 并找到了这个问题,但它没有为我解决问题;对于这个 Git 问题也是如此。
我的示例代码如下:
X509TrustManager trustManager = new X509TrustManager() {
public void checkClientTrusted(X509Certificate[] xcs, String string)
throws CertificateException {}
public void checkServerTrusted(X509Certificate[] xcs, String string)
throws CertificateException {}
public X509Certificate[] getAcceptedIssuers() {
return null;
}
};
SSLContext sslContext;
SSLSocketFactory sslSocketFactory = null;
try {
sslContext = SSLContext.getInstance("TLS");
sslContext.init(null, new TrustManager[]{trustManager}, null);
sslSocketFactory = sslContext.getSocketFactory();
} catch (Exception e){
e.printStackTrace();
}
OkHttpClient client = new OkHttpClient.Builder().sslSocketFactory(sslSocketFactory,
trustManager).addInterceptor(interceptor).build();
Run Code Online (Sandbox Code Playgroud)
当发送的参数全部有效且不为空时,为什么我会收到错误?
我正在开发一个必须支持API级别16的项目,并要求我对动态URL进行网络调用.我遇到的问题是服务器最近不得不将TLS更新为1.2以实现PCI合规性,默认情况下在Android API 16-19上禁用.虽然启用此功能并不困难,但我遇到了仅针对这些API级别的X509证书问题.
我对它做了很多研究,虽然所有这些链接都很有用:
1)如何在Android应用程序中启用TLS 1.2支持(在Android 4.1 JB上运行)
2)如何使用自签名证书连接到Android(paho客户端)中的Mqtt服务器?
4)允许Java使用不受信任的证书进行SSL/HTTPS连接
6)SSLHandshakeException:未找到证书路径的信任锚.仅适用于Android API <19
他们没有解决我遇到的核心问题,即我看到了这个例外:
com.android.volley.NoConnectionError: javax.net.ssl.SSLHandshakeException: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found.
at com.android.volley.toolbox.BasicNetwork.performRequest(BasicNetwork.java:151)
at com.android.volley.NetworkDispatcher.run(NetworkDispatcher.java:112)
Caused by: javax.net.ssl.SSLHandshakeException: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found.
at com.android.org.conscrypt.OpenSSLSocketImpl.startHandshake(OpenSSLSocketImpl.java:409)
at com.android.okhttp.Connection.upgradeToTls(Connection.java:146)
at com.android.okhttp.Connection.connect(Connection.java:107)
at com.android.okhttp.internal.http.HttpEngine.connect(HttpEngine.java:294)
at com.android.okhttp.internal.http.HttpEngine.sendSocketRequest(HttpEngine.java:255)
at com.android.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:206)
at com.android.okhttp.internal.http.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:345)
at com.android.okhttp.internal.http.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:296)
at com.android.okhttp.internal.http.HttpURLConnectionImpl.getResponseCode(HttpURLConnectionImpl.java:503)
at com.android.okhttp.internal.http.HttpsURLConnectionImpl.getResponseCode(HttpsURLConnectionImpl.java:136)
at com.android.volley.toolbox.HurlStack.performRequest(HurlStack.java:110)
at com.android.volley.toolbox.BasicNetwork.performRequest(BasicNetwork.java:96)
... 1 more
Run Code Online (Sandbox Code Playgroud)
当我尝试连接到需要TLS1.2的URL时,例如https://www.ssllabs.com/ssltest/viewMyClient.html. …
我目前正在编写一些代码,这些代码将在 Person 类型的向量中进行搜索(我已在代码中定义了该向量,并且将在需要时显示)。如果找到这个人,就会返回他们的名字。这目前正在工作,但如果它没有找到该人,它应该返回一个空指针。问题是,我不知道如何让它返回空指针!它只是每次都会使程序崩溃。
代码:
Person* lookForName(vector<Person*> names, string input)
{
string searchName = input;
string foundName;
for (int i = 0; i < names.size(); i++) {
Person* p = names[i];
if (p->getName() == input) {
p->getName();
return p; //This works fine. No problems here
break;
} else {
//Not working Person* p = NULL; <---Here is where the error is happening
return p;
}
}
}
Run Code Online (Sandbox Code Playgroud) 我即将在我的应用商店上发布一个发布版本。调试版本(我用我的手机代替模拟器),完美运行,没有任何问题。
然而,“签名 APK”版本根本没有连接到后端。
我如何在 Android Studio 中生成签名的 APK:
构建 --> 生成签名的 APK
创建一个新的密钥库(使用密码)
构建类型 == 发布。
通过移动实际的 APK 文件本身并允许从未知来源安装,将其安装到手机上。
我的标准请求(IE Signin、getUser、GetSomethingX)都出错了。这被证明是一个比我最初想象的更大的问题,因为我无法弄清楚如何测试日志打印语句并在日志猫中查看它们。当然,我可以使用 Toasts,但是尝试以这种方式阅读它有点痛苦。我编写的实际代码的调试版本和发布版本之间没有区别。
问题:为什么我的 APK 的调试版本可以完美运行,但构建/发布版本却不能?我一直在与后端的网络人员来回走动,我们不确定谁有错。应用程序的调试版本和发布版本之间是否存在本质上的不同,可能会阻止其正常工作?
有人知道吗?
谢谢大家!
-Sil