App build.gradle:
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Run Code Online (Sandbox Code Playgroud)Code App build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
defaultConfig {
applicationId "com.example.jimclermonts.myapplication"
minSdkVersion 21
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: …Run Code Online (Sandbox Code Playgroud)我收到此错误:
Permission name C2D_MESSAGE is not unique (appears in both my.packagename.permission.C2D_MESSAGE and my.packagename.acc.permission.C2D_MESSAGE) (Previous permission here)
Run Code Online (Sandbox Code Playgroud)
在我的 Android 清单中:
<permission
android:name="my.packagename.permission.C2D_MESSAGE"
android:protectionLevel="signature" />
<uses-permission android:name="my.packagename.permission.C2D_MESSAGE" />
Run Code Online (Sandbox Code Playgroud)
问题是在将 applicationIdSuffix 添加到 build.gradle 中的一个风味之后开始的(乍一看似乎与它无关)。
构建.gradle:
flavorDimensions "type"
productFlavors {
acceptance {
dimension="type"
applicationIdSuffix ".acc"
versionNameSuffix "-acc"
}
production {
dimension="type"
applicationIdSuffix ""
versionNameSuffix ""
}
}
Run Code Online (Sandbox Code Playgroud)
应用程序.java:
if (BuildConfig.DEBUG) {
GoogleAnalytics.getInstance(context).setDryRun(true);
} else {
setupGoogleAnalytics();
}
Run Code Online (Sandbox Code Playgroud)
我创建了google-services.json的副本。
我已将 google-services.json 添加到:
app\src\acceptance\google-services.json (fake numbers)
app\src\production\google-services.json
Run Code Online (Sandbox Code Playgroud)
我为接受中的键设置了不同的虚假值。我不希望在接受版本中使用 Google Analytics。所以我不想创建单独的 google-services.json。这可能吗?
重新安装应用程序并具有allowBackup = true时,我无法从共享的“首选项”中检索值(在Android 9.0设备上)。
<manifest ... >
...
<application android:allowBackup="true" ... >
...
</application>
</manifest>
Run Code Online (Sandbox Code Playgroud)
据此:https : //developer.android.com/guide/topics/data/autobackup
共享的首选项应该恢复吗?
SharedPreferences prefs = getSharedPreferences("TEST", MODE_PRIVATE);
String name = prefs.getString("name", "No name defined");//"No name defined" is the default value.
int idName = prefs.getInt("idName", 0); //0 is the default value.
SharedPreferences.Editor editor = getSharedPreferences("TEST", MODE_PRIVATE).edit();
editor.putString("name", "Elena");
editor.putInt("idName", 12);
editor.apply();
Run Code Online (Sandbox Code Playgroud)
下面,我按照以下步骤中描述的步骤进行操作:https : //developer.android.com/guide/topics/data/testingbackup.html#Preparing
adb shell
dreamlte:/ $ bmgr enabled
Backup Manager currently enabled
dreamlte:/ $ bmgr list transports
android/com.android.internal.backup.LocalTransport …Run Code Online (Sandbox Code Playgroud) 打开应用程序后,我希望删除徽章计数。目前,只有当我通过锁定屏幕中的推送消息打开应用程序时,它才会被删除。然后推送消息将从锁定屏幕中删除,因此我也可以将这个问题表述为“如何从锁定屏幕中删除推送消息”。
使用此代码我可以检索通知:
@Override
protected void onStart() {
super.onStart();
NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M) {
StatusBarNotification[] notifications = notificationManager.getActiveNotifications();
for (StatusBarNotification statusBarNotification : notifications) {
statusBarNotification.getNotification().number = 0;
}
}
}
Run Code Online (Sandbox Code Playgroud)
但当将数字设置为 0 时,没有任何反应。
我已经建立了一个在 microsoft azure pipelines中运行我的测试的管道。在我的本地机器上,这工作正常,该jetified-libidpmobile-debug.jar文件位于我机器上的 gradle 系统目录中:
/Users/jimclermonts/.gradle/caches/transforms-2/files-2.1/efad9765ab457848824459e0c76abddc/jetified-libidpmobile-debug.jar
Run Code Online (Sandbox Code Playgroud)
这是我的build.gradle:
debugImplementation files('libs/libidpmobile-debug.jar')
Run Code Online (Sandbox Code Playgroud)
据我了解,jetified-libidpmobile-debug.jar是由jetifier从libidpmobile-debug.jar文件中自动创建的。
输出:
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:kaptDebugKotlin'.
> Could not resolve all files for configuration ':app:_classStructurekaptDebugKotlin'.
> Failed to transform file 'jetified-libidpmobile-debug.jar' to match attributes {artifactType=class-structure, org.gradle.libraryelements=jar, org.gradle.usage=java-runtime}
> Execution failed for StructureArtifactTransform: /Users/iosadmin/.gradle/caches/transforms-2/files-2.1/1e14bb7ec832a0c2c967e6c977ddd9b9/jetified-libidpmobile-debug.jar.
> error in opening zip file
Run Code Online (Sandbox Code Playgroud)
这是我的 azure-pipelines.yml 中组装调试和测试单元测试的部分:
trigger:
- master
pool: …Run Code Online (Sandbox Code Playgroud) 它以前工作过。但现在它没有了。IDE 只显示“实例化测试...”。但是当我等了 10 分钟时,突然它就起作用了?机器是 2015 年中的 Macbook Pro。问题只出现在androidTest,test目录工作正常。
@LargeTest
@RunWith(AndroidJUnit4::class)
class SomeTestClass {
@get:Rule
var activityTestRule = ActivityTestRule(
NavigationActivity::class.java, false, false)
@Before
fun before() {
Timber.d("When debugging, this triggers only after about 10 minutes.")
}
@Test
fun testContents() {
Assert.assertEquals(0, 0)
}
}
Run Code Online (Sandbox Code Playgroud)
日志不断输出:
D/EZIO_NLOG: watchdog_routine executed!
D/EZIO_NLOG: check1
check1
check2
check2
Run Code Online (Sandbox Code Playgroud)
尝试了以下事情:
我想要一条虚线,如官方文档中所述:
futureSeries.setDrawDataPoints(true);
Paint paint = new Paint();
paint.setStyle(Paint.Style.STROKE);
paint.setStrokeWidth(10);
paint.setPathEffect(new DashPathEffect(new float[]{8, 5}, 0));
futureSeries.setCustomPaint(paint);
graph.addSeries(futureSeries);
Run Code Online (Sandbox Code Playgroud)
build.gradle:
compile 'com.jjoe64:graphview:4.2.1'
Run Code Online (Sandbox Code Playgroud)
结果不是虚线:
这样的事情就可以了:
我正在开发一个新的 iOS/Android 应用程序,我需要 Firestore 本机模式。在我的旧项目中,我看到了我的 Cloud Firestore(本机模式),但在我的新项目中,我想我不小心在某处选择了 Data-store,但我还没有添加数据。我怎么能恢复这个,因为我不想开始一个完整的新项目。
我已阅读此文档
旧项目:
我在 Android Studio 中启动了一个新项目并将其添加到我的androidmanifest.xml:
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE"/>
<data
android:host="www.example.com"
android:pathPrefix="/gizmos"
android:scheme="http"/>
</intent-filter>
</activity>
Run Code Online (Sandbox Code Playgroud)
然后我转到 Google Chrome 并输入:http://www.example.com/gizmos。该应用程序打不开。然后尝试命令行:
mac-van-jim:DeeplinkTest jimclermonts$ adb shell am start -n eu.theappfactory.deeplinktest/MainActivity
Starting: Intent { cmp=eu.theappfactory.deeplinktest/MainActivity }
Error type 3
Error: Activity class {eu.theappfactory.deeplinktest/MainActivity} does not exist.
Run Code Online (Sandbox Code Playgroud)
和这个:
mac-van-jim:DeeplinkTest jimclermonts$ adb shell am start -W -a android.intent.action.VIEW -d "http://www.example.com" eu.theappfactory
Starting: Intent { act=android.intent.action.VIEW dat=http://www.example.com/... pkg=eu.theappfactory }
Error: Activity …Run Code Online (Sandbox Code Playgroud) android ×9
gradle ×2
build.gradle ×1
deep-linking ×1
firebase ×1
ios ×1
java ×1
kotlin ×1
objective-c ×1
paint ×1
testing ×1
uri ×1
xcode ×1