小编Jim*_*nts的帖子

如何添加/删除工件以平移Android Studio

  1. 打开Android Studio
  2. 创建新项目
  3. 打开Build.gradle并添加一个输入(触发重新同步的任何内容)
  4. 单击"重新同步"按钮
  5. 看下面的图片,它从我想要删除的网址开始提取: 在此输入图像描述

  6. 当我点击"run"时,它也会从这个url开始获取.使总构建时间更长. 在此输入图像描述

  7. 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)
  8. 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)

android gradle build.gradle android-gradle-plugin

5
推荐指数
1
解决办法
593
查看次数

权限名称 C2D_MESSAGE 不是唯一的,同时出现在 C2D_MESSAGE 中

我收到此错误:

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。这可能吗?

简单地删除 …

android google-play-services

5
推荐指数
1
解决办法
3087
查看次数

重新安装后从SharedPreferences中检索值,并使用Android自动备份使用allowBackup = true进行检索

重新安装应用程序并具有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)
  • 我已经在手机上登录了我的Gmail帐户,当转到“云端硬盘”应用程序,“备份”,“应用程序数据”时,我看到了18个应用程序,例如Youtube,Gmail等,还有我自己的应用程序。
  • 当我转到“设置>系统>备份”时,我看到相同的应用程序,也看到了自己的应用程序。因此,我希望备份管理器保存这些值。

下面,我按照以下步骤中描述的步骤进行操作: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)

android sharedpreferences

5
推荐指数
1
解决办法
125
查看次数

当 Android 应用程序在 Android 上打开时如何重置徽章计数

打开应用程序后,我希望删除徽章计数。目前,只有当我通过锁定屏幕中的推送消息打开应用程序时,它才会被删除。然后推送消息将从锁定屏幕中删除,因此我也可以将这个问题表述为“如何从锁定屏幕中删除推送消息”。

使用此代码我可以检索通知:

@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 时,没有任何反应。

android

5
推荐指数
1
解决办法
5169
查看次数

Gradle 错误:无法将文件转换为匹配属性 jetified

我已经建立了一个在 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是由jetifierlibidpmobile-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)

android gradle azure-pipelines

5
推荐指数
1
解决办法
746
查看次数

Android 测试用例只能在等待 10 分钟后在调试模式下进行调试

它以前工作过。但现在它没有了。IDE 只显示“实例化测试...”。但是当我等了 10 分钟时,突然它就起作用了?机器是 2015 年中的 Macbook Pro。问题只出现在androidTesttest目录工作正常。

@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)

尝试了以下事情:

  1. 文件,使缓存无效/重新启动
  2. 试过这个答案。但它似乎已经过时了。
  3. 编辑配置...,选择“All in Package”、“Class”和“Method”。他们都没有工作。
  4. 当我等待很长时间时,比如 10 分钟,然后它突然触发并起作用。

在此处输入图片说明 在此处输入图片说明

testing android kotlin

5
推荐指数
1
解决办法
104
查看次数

如何在Xcode中删除手势识别器?

我不知道如何删除手势识别器.非常感谢你们.

我怎样才能删除这些?

xcode objective-c

4
推荐指数
1
解决办法
1349
查看次数

GraphView中的虚线

我想要一条虚线,如官方文档中所述

    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)

结果不是虚线:

在此处输入图片说明

这样的事情就可以了:

在此处输入图片说明

java android paint android-custom-view android-graphview

3
推荐指数
1
解决办法
1601
查看次数

如何为新项目禁用 Firestore Datastore 模式并切换到本机模式

我正在开发一个新的 iOS/Android 应用程序,我需要 Firestore 本机模式。在我的旧项目中,我看到了我的 Cloud Firestore(本机模式),但在我的新项目中,我想我不小心在某处选择了 Data-store,但我还没有添加数据。我怎么能恢复这个,因为我不想开始一个完整的新项目。

我已阅读此文档

旧项目:

在此处输入图片说明

当前一: 在此处输入图片说明

创建 1 个实体并删除同一实体后,无法再切换到本机: 在此处输入图片说明

android ios firebase google-cloud-datastore

3
推荐指数
1
解决办法
1780
查看次数

深层链接在 Android 中不再起作用

我在 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 uri deep-linking

2
推荐指数
1
解决办法
6285
查看次数