我正在使用本教程:https : //firebase.google.com/docs/auth/admin/create-custom-tokens#using_a_service_account_id
创建一个 node.js 函数(部署到谷歌云函数)来验证我的用户。功能超级简单:
const admin = require('firebase-admin');
admin.initializeApp({
serviceAccountId: 'authenticator@igibo-b0b27.iam.gserviceaccount.com'
});
exports.authenticate = (req, res) => {
let pass;
let uid;
if (req.query) {
if (req.query.v == 3) {
pass = req.query.p;
uid = req.query.u;
}
admin.auth().createCustomToken(uid)
.then(function(customToken) {
res.status(200).send(customToken);
return customToken;
})
.catch(function(error) {
console.error("Error creating custom token:" + JSON.stringify(error));
res.status(400).send(error);
});
} else {
console.error("EMPTY to authentication");
res.end();
}
};
Run Code Online (Sandbox Code Playgroud)
但我收到了这个烦人的错误:
{"code":"auth/insufficient-permission","message":"Permission iam.serviceAccounts.signBlob is required to perform this operation on service account projects/-/serviceAccounts/authenticator@igibo-b0b27.iam.gserviceaccount.com.; Please …Run Code Online (Sandbox Code Playgroud) 我正在使用 Retrofit 和 OkHttpClient 在 Android 上构建 Rest API。
前一段时间,我注意到 api 发出的第一个请求总是比其他所有请求花费更长的时间来处理......一开始我并不关心,因为这是一个可以接受的时间。
但突然请求时间跳到了 60 秒
所有这些时间都是浪费客户端,因为监控服务器我发现处理时间不到 1 秒......
我想知道我做了什么更改会导致如此高的影响,然后我意识到我更改了 OkHttp 的连接超时。
我已将值从 10 秒更改为 60 秒只是为了测试......
我做了一些实验,将 connectTimeout 设置为许多其他值,并且第一个请求的时间始终远远高于超时
有谁知道是什么可能导致这种奇怪的行为?怎么解决呢?
附言。我需要在桌面上测试 api,但这个问题没有发生,我的意思是它只发生在 Android 设备上 [我尝试了几个] 原因是什么?
我有一个应用程序,每天下载量超过5000次,每天活跃着500多个用户,无处不在,我开始在Crashlytics上遇到一个奇怪的错误:
Caused by android.content.res.Resources$NotFoundException: File res/drawable-anydpi-v24/ic_tickets.xml from drawable resource ID #0x7f0700b3
at android.content.res.Resources.loadDrawableForCookie(Resources.java:2748)
at android.content.res.Resources.loadDrawable(Resources.java:2643)
at android.content.res.TypedArray.getDrawable(TypedArray.java:870)
at android.widget.TextView.<init>(TextView.java:921)
at android.widget.TextView.<init>(TextView.java:703)
at android.support.v7.widget.AppCompatTextView.<init>(AppCompatTextView.java:76)
at android.support.v7.widget.AppCompatTextView.<init>(AppCompatTextView.java:72)
at java.lang.reflect.Constructor.newInstance(Constructor.java)
Caused by android.content.res.Resources$NotFoundException: File res/drawable-anydpi-v24/$ic_tickets__0.xml from color state list resource ID #0x7f070017
at android.content.res.Resources.loadColorStateListForCookie(Resources.java:2858)
at android.content.res.Resources.loadColorStateList(Resources.java:2807)
at android.content.res.TypedArray.getColor(TypedArray.java:439)
at android.graphics.drawable.VectorDrawable$VFullPath.updateStateFromTypedArray(VectorDrawable.java:1605)
at android.graphics.drawable.VectorDrawable$VFullPath.inflate(VectorDrawable.java:1584)
at android.graphics.drawable.VectorDrawable.inflateInternal(VectorDrawable.java:666)
at android.graphics.drawable.VectorDrawable.inflate(VectorDrawable.java:571)
at android.graphics.drawable.Drawable.createFromXmlInner(Drawable.java:1215)
at android.graphics.drawable.Drawable.createFromXml(Drawable.java:1124)
Caused by org.xmlpull.v1.XmlPullParserException: Binary XML file line #6: invalid color state list tag gradient
at android.content.res.ColorStateList.createFromXmlInner(ColorStateList.java:217)
at android.content.res.ColorStateList.createFromXml(ColorStateList.java:201)
at android.content.res.Resources.loadColorStateListForCookie(Resources.java:2854)
at android.content.res.Resources.loadColorStateList(Resources.java:2807)
at …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用Google Play安装Referrer API为用户创建一种透明的方式来共享我的应用并获得收益...但是我在噩梦中尝试测试此api
我的应用程序有一个按钮,当用户按下它时,会获得一个链接,该链接可以在其他应用程序上共享,例如:
https://play.google.com/store/apps/details?id=blablabla&referrer=utm_source%3Dapp_referral%26referrer%3DUSERID
我实际上可以app_referral在Google信息中心上跟踪,但是我的目标是USERID在运行时获得用户的好评。
我已经阅读了大量关于以下内容的文章:https : //developer.android.com/google/play/installreferrer/library没有一个提供有关如何返回值或如何测试的真实示例。甚至建议在Google Play上发布仅用于测试的测试应用
所以我的问题是:我该如何测试?如果方法很复杂,能否为我提供一些如何返回的示例?
它将返回this:https://play.google.com/store/apps/details?id=blablabla&referrer=utm_source%3Dapp_referral%26referrer%3DUSERID
或this:referrer=utm_source%3Dapp_referral%26referrer%3DUSERID
或this:utm_source%3Dapp_referral%26referrer%3DUSERID
并在发起安装的网址上没有引荐来源网址?
请任何帮助表示赞赏
android google-play install-referrer google-play-developer-api
我有一个噩梦试图在 android 上创建一个永久运行的简单后台服务。
此服务将执行一些后台任务,例如池用户社交媒体和显示通知,因此它只需要一次用户交互(登录)之后应该能够永远运行直到日子结束......
但它没有发生
这是我的清单:
<service
android:name=".service.MyService"
android:description="@string/serviceDescription"
android:directBootAware="false"
android:enabled="true"
android:exported="false"
android:icon="@drawable/ic_logo"
android:label="@string/serviceLabel"/>
Run Code Online (Sandbox Code Playgroud)
我开始服务 Application onCreate()
if (MyService.getInstance() == null) {
Intent intent = new Intent(this, MyService.class);
startService(intent);
}
Run Code Online (Sandbox Code Playgroud)
服务:
public void onCreate() {
super.onCreate();
this.workDone = 0;
this.workerMap = new HashMap<User.UserData, Worker>(3);
this.listeners = new HashMap<Worker, Worker.WorkerListener>(3);
this.usernames = new HashMap<APIFacade, List<String>>(3);
this.threadPool = Executors.newFixedThreadPool(3);
INSTANCE = this;
}
Run Code Online (Sandbox Code Playgroud)
在我的代码中绝对没有我调用 STOPSERVICE 或 STOPSELF
那么为什么在某些随机情况下我会得到 nullpointerexception 呢?
有人甚至告诉我执行以下代码以强制 android“重新启动”服务
@Override
public int onStartCommand(Intent intent, int flags, int startId) { …Run Code Online (Sandbox Code Playgroud) I'm having an weird problem with google admob api for android.... I dont know exactly how and when but it start creating too many threads and end up by crashing the whole system. I got this error in production and still not able to reproduce it in dev
this is the stack:
Fatal Exception: java.lang.OutOfMemoryError: pthread_create (1040KB stack) failed: Try again
at java.lang.Thread.nativeCreate(Thread.java)
at java.lang.Thread.start(Thread.java:1063)
at java.util.concurrent.ThreadPoolExecutor.addWorker(ThreadPoolExecutor.java:921)
at java.util.concurrent.ThreadPoolExecutor.execute(ThreadPoolExecutor.java:1339)
at com.google.android.gms.ads.internal.util.future.ac.execute(ac.java)
at com.google.android.gms.ads.nonagon.ad.activeview.b.a(b.java:5)
at com.google.android.gms.ads.internal.webview.j.a(j.java:30)
at com.google.android.gms.ads.internal.webview.ad.a(ad.java:4)
at com.google.android.gms.ads.internal.webview.ae.run(ae.java:2)
at …Run Code Online (Sandbox Code Playgroud) 我正在用来OkHttp + Retrofit2构建第三方系统的 api。
我注意到,即使使用一个ConnectionPool线程和多个线程,Retrofit 也不会同时进行调用。
这就是我创建服务的方式:
OkHttpClient.Builder httpClientBuilder = new OkHttpClient.Builder();
httpClientBuilder.connectionPool(new ConnectionPool(7, 1, TimeUnit.MINUTES););
Dispatcher dispatcher = new Dispatcher();
dispatcher.setMaxRequests(10);
dispatcher.setMaxRequestsPerHost(10);
httpClientBuilder.dispatcher(dispatcher);
OkHttpClient okhttp = httpClientBuilder.build();
this.service = new Retrofit.Builder().baseUrl(API_URL).addConverterFactory(GsonConverterFactory.create(getGson())).client(okhttp).build().create(IService.class);
Run Code Online (Sandbox Code Playgroud)
为了简化 IService.class,假设它只有 2 个方法:
@GET
Call<JsonElement> get(@Url String url, @HeaderMap Map<String, Object> headers, @QueryMap Map<String, Object> query);
@POST
Call<ResponseBody> complexPost(@Url String url, @HeaderMap Map<String, Object> headers, @QueryMap Map<String, Object> query, @Body RequestBody body);
Run Code Online (Sandbox Code Playgroud)
现在这就是我尝试发出并行请求的方式:
public static void main(String[] args) {
final Map<String,Object> empty = …Run Code Online (Sandbox Code Playgroud) 我在生产中遇到了 Crashlytics 在少数用户中报告的奇怪异常...我没有太多信息,所以我无法重现它,但我会粘贴 crashlytics 告诉我的所有内容
@SuppressLint("StringFormatMatches")
private void updateForegroundNotification(ServiceStatus status, Object extra) {
Intent notificationIntent = new Intent(this, LoginActivity.class);
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0);
String text = "sample";
NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this, Constants.SERVICE_STATUS_NOTIFICATION_CHANNEL_ID)
.setSmallIcon(R.drawable.ic_notification_logo)
.setContentTitle(getString(R.string.foregroundNotification))
.setContentText(text)
.setPriority(NotificationCompat.PRIORITY_LOW)
.setContentIntent(pendingIntent);
startForeground(Constants.ID_FOREGROUND_NOTIFICATION, mBuilder.build());//line 656
}
Run Code Online (Sandbox Code Playgroud)
堆栈跟踪
Fatal Exception: java.lang.NullPointerException: Attempt to read from field 'int com.android.server.am.UidRecord.curProcState' on a null object reference
at android.os.Parcel.createException(Parcel.java:1959)
at android.os.Parcel.readException(Parcel.java:1921)
at android.os.Parcel.readException(Parcel.java:1871)
at android.app.IActivityManager$Stub$Proxy.setServiceForeground(IActivityManager.java:5084)
at android.app.Service.startForeground(Service.java:695)
at com.tomatedigital.giveawaymaster.service.IgiboService.updateForegroundNotification(IgiboService.java:656)
at com.tomatedigital.giveawaymaster.service.IgiboService.login(IgiboService.java:292)
at com.tomatedigital.giveawaymaster.activity.LoginActivity.lambda$doLogin$29(LoginActivity.java:770)
at com.tomatedigital.giveawaymaster.activity.-$$Lambda$LoginActivity$p3_-EGA6SkYcNhRTdeIvZZogf6k.run(-.java:2)
at …Run Code Online (Sandbox Code Playgroud) 我有一个正在生产的 android 应用程序,在 google play 上的下载量超过 500k,一些用户(我不知道为什么)在登录时出现这个错误......
com.google.firebase.FirebaseNetworkException: A network error (such as timeout, interrupted connection or unreachable host)
at com.tomatedigital.giveawaymaster.task.LoginTask.lambda$firebaseAuth$1(LoginTask.java:249)
at com.tomatedigital.giveawaymaster.task.-$$Lambda$LoginTask$p6eSSF8vZ2BATwhlFttcJl8qT-w.onComplete(-.java)
at com.google.android.gms.tasks.zzi.run(zzi.java:4)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
at java.lang.Thread.run(Thread.java:818)
Run Code Online (Sandbox Code Playgroud)
这些用户、不同的安卓版本、不同的手机型号之间没有简单的关联......
我发现了这个老问题:https : //github.com/firebase/firebase-android-sdk/issues/384但似乎 firebase 团队中的某个人只是把它放在地毯下而不是解决它(在那里很常见)
错误发生在生产中的真实设备中,我在应用程序中嵌入了一个小聊天,一些有问题的用户前来支持,我要求重新安装应用程序,但他们仍然出现错误......这也不是互联网连接问题因为人们在在线聊天中与我交谈并同时遇到问题
crashlytics 显示它发生在 1% 的会话中......
相关代码:
FirebaseAuth.getInstance().signInWithCustomToken(token).addOnCompleteListener(AsyncTask.THREAD_POOL_EXECUTOR, task -> {
if (task.isSuccessful()) {
FirebaseCrashlytics.getInstance().log("new firebase token successfully authenticated");
} else {
App.shouldNeverHappen(new RuntimeException(task.getException().getMessage() + " data: " + sb.toString()));
this.exception = task.getException();
}
});
//token is generated …Run Code Online (Sandbox Code Playgroud) 我知道stackoverflow并非适用于Google产品的帮助台,但是Google帮助台本身并没有帮助,因此也许这里的其他人也遇到了同样的问题,可以帮助我解决。
我有一个过去3个月在Google Play上发布的应用
所有应用程序的东西都已正确连接,firebase-> admob-> google play控制台-> adsense ...所有操作均在过去3个月内完成
但上周,由于任何原因,应用程序未进行任何更新或这些工具的任何设置发生更改,firebase仪表板停止显示admob收入
正如您在这张图表上看到的,它认为从11月16日到22日我的应用程序的admob收入仅为0.17
但是在admob本身上
蓝色的条形图是admob的收入,而绿色的条形图是应用内购买的,因此它一直在注册,admob图表不显示admob的收入总和,但无需成为天才即可看到其大约70.00的价格0.17
我已经在firebase-> events选项卡中签入,并且仍在计算所有事件,例如ad_click ad_reward ad_impression
有谁知道可能是什么?
再次:这个工作大约3个月的工作时间停了,因为上个星期我不知道原因
我要求在Firebase上提供支持,但是那家伙只是向我指出了一些我已经遵循但不能解决我的问题的指南。
https://support.google.com/firebase/answer/7378163?hl=zh_CN https://support.google.com/firebase/answer/6387949