我有一个自定义视图库,可以自己编译和运行(通过在库项目中为测试目的而创建的另一个活动).然而,当我构建库,然后将aar导入另一个项目(打开模块设置 - >新模块 - >现有的aar ..)我得到一个运行时ClassNotFoundException - 异常是关于库的唯一gradle依赖项使用.为什么会这样?
库gradle文件:
apply plugin: 'com.android.library'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile 'com.googlecode.libphonenumber:libphonenumber:7.2.1'
}
Run Code Online (Sandbox Code Playgroud)
我得到的错误:
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.i18n.phonenumbers.PhoneNumberUtil" on path: DexPathList[[zip file..
Run Code Online (Sandbox Code Playgroud) android gradle classnotfoundexception android-library android-gradle-plugin
我创建了一个接收器来接收和显示推送通知 - 当用户按下推送通知时,它会在我的应用程序中打开一个深层链接.问题是,当用户按下"后退"时,他不会退回到主屏幕,而是在应用程序Backstack之前进入我的应用程序打开的任何屏幕 - 即使应用程序在他按下之前被最小化通知.
我需要的行为是让用户在主屏幕上,让他打开通知面板,按下我的通知,进入我的应用程序的深层链接页面,当他按下后退按钮时 - 我想要他再次退出到主屏幕.我不希望他以任何方式与主要应用程序的后台交互.
我在推送通知中尝试了pendingIntent的多种标志组合.一切从FLAG_ACTIVITY_TASK_ON_HOME到FLAG_ACTIVITY_NEW_TASK到FLAG_ACTIVITY_SINGLE_TOP等等.没有任何组合似乎能给我我想要的东西 - 在每一个案例中,打开与应用程序最小化的深层链接将始终返回到应用程序历史记录中的下一页后退按钮.我怎么解决这个问题?
示例代码:
Intent notificationIntent = new Intent(this, DeepLink.class);
notificationIntent.setData(Uri.parse(url));
notificationIntent.addFlags(Intent.FLAG_ACTIVITY_TASK_ON_HOME);
notificationIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
PendingIntent pendingIntent = PendingIntent.getActivity(getBaseContext(), 1, notificationIntent, 0);
Run Code Online (Sandbox Code Playgroud) 在我的xml中,我有以下代码:
<fragment android:name="somepackage.Fragments.ToolbarFragment"
android:id="@+id/toolbar_fragment"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
Run Code Online (Sandbox Code Playgroud)
在我的代码中我有:
private ToolbarFragment toolbarFragment;
toolbarFragment = (ToolbarFragment) findViewById(R.id.toolbar_fragment);
Run Code Online (Sandbox Code Playgroud)
我收到错误:"无法将android.view.View强制转换为somepackage.Fragments.ToolbarFragment"
为什么android将片段视为通用视图类型而不是我指定的片段类?
我正在调用ActivityCompat.requestPermissions以获取android M下的权限,但是,这需要参数中的活动.这很好,除了我想从单身人士调用它,单身人士可以被应用程序中的任何活动使用.
ActivityCompat.requestPermissions(context, PERMISSIONS_LOCATION, REQUEST_LOCATION);
Run Code Online (Sandbox Code Playgroud)
我想避免对单例中的任何活动进行引用,因为这是内存泄漏的可靠方法,而且我更喜欢单例根本不进行活动,因为它在所有调用的活动中需要无用的代码(他们中的每一个都必须在getInstance()中包含一个额外的参数,以便单例持有一个活动 - 单例需要从某个地方获取活动.
现在,我可以在技术上获得一个活动,然后在我请求许可后将其设置为null,但是在我调用单例的每个活动中,仍然会留下大量无用的活动参数.是否有一个更优雅的解决方案,我只是没有看到这个问题?
每次构建任何项目时,我都会收到以下 crashlytics 错误:
java.io.IOException: Crashlytics could not read the
com.crashlytics.android.build_id as a value string
Run Code Online (Sandbox Code Playgroud)
有没有人遇到过这个错误?它是什么意思,它来自哪里以及如何解决它?它发生在名为 crashlyticsStoreDeobsRelease 的步骤中
到目前为止我尝试过的步骤来解决这个问题:
编辑:这肯定与最新版本的 Android Studio(V1.1 beta 4)有关 - 因为它发生在我尝试在此版本下运行的所有项目中
编辑 #2:显然这与 V1.1 beta 4 无关。我尝试安装稳定版本 v1.0.1,但它仍然出现在那里:/
编辑 #3:我注意到文件
- crashlytics-build.properties
- crashlytics.properties
- com_crashlytics_export_strings.xml …Run Code Online (Sandbox Code Playgroud) api 21上的以下代码显示了一个矩形的轮廓,黑色边框的宽度为1像素:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<stroke android:width="1dp" android:color="#000000" />
<size android:width="300dp" android:height="50dp"/>
</shape>
Run Code Online (Sandbox Code Playgroud)
然而,在api 16上,我看到一个坚实的黑色矩形.为什么会这样,是否有解决方法?
编辑:在logcat中我看到连续的消息:
HardwareRenderer? draw surface is valid dirty= Rect(107, 214 - 109, 251)
Run Code Online (Sandbox Code Playgroud) 有没有一种不需要 Google Play 服务就可以实现 Google 登录的方法?我知道官方文档说你需要 GPS:
• https://developers.google.com/identity/sign-in/android/start-integrating
但是我也在这里发现了相互矛盾的信息:
•没有 Google Play 服务的 Google Plus 登录
也就是说,使用 Google+ Api 您可以在用户没有 GPS 的情况下实现登录。哪个是真的?从技术上讲,您可以在没有 GPS 的情况下实现登录吗?如果可以的话,对于因任何原因无法下载 GPS 的用户来说,作为后备使用会很好。
android google-play-services google-plus-signin android-googleapiclient google-signin
我想显示一个折叠/展开的工具栏布局,在右上角有一个图标 - 处于展开和折叠状态。图标根本不应该移动。
如果我使用 layout_gravity 并写“top”,那么当布局折叠时图标不可见,如果我写“bottom”,那么当布局展开时图标不会显示在顶部。我该如何解决这个问题?
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/rootLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
<android.support.design.widget.AppBarLayout
android:id="@+id/appbar"
android:layout_width="match_parent"
android:layout_height="220dp"
android:fitsSystemWindows="true"
>
<android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/collapsingToolbar"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
app:collapsedTitleGravity="center"
app:expandedTitleGravity="bottom|start"
app:layout_scrollFlags="scroll|exitUntilCollapsed"
>
<ImageView
android:id="@+id/backgroundImage"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:contentDescription="@null"
android:scaleType="centerCrop"
android:fitsSystemWindows="true"
app:layout_collapseMode="parallax"
/>
<FrameLayout
android:id="@+id/shadow"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/black_40percent_opacity"
/>
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
app:layout_collapseMode="pin"
/>
<ImageView
android:id="@+id/iconToShow"
android:layout_width="56dp"
android:layout_height="56dp"
android:src="@drawable/some_drawable"
android:padding="16dp"
android:layout_gravity="top|end"
/>
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
</android.support.design.widget.CoordinatorLayout>
Run Code Online (Sandbox Code Playgroud) android android-layout android-actionbar-compat android-toolbar android-collapsingtoolbarlayout
我想为我的应用设置应用链接,但仅限于它在某些路径上有效.换句话说,在我的清单中:
<intent-filter android:autoVerify="true">
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="http" android:host="www.mydomain.com/[mypath]" />
<data android:scheme="https" android:host="www.mydomain.com/[mypath]" />
</intent-filter>
Run Code Online (Sandbox Code Playgroud)
我不希望每个拥有我的域名的网址都能打开应用程序 - 他们可以照常在浏览器中打开.我只想要在应用程序中打开包含特定子路径的URL.这种模式是允许的还是应用程序链接的"全有或全无"?
链接到开发人员文档:http: //developer.android.com/training/app-links/index.html
我的清单中有以下行:
<intent-filter android:autoVerify="true">
Run Code Online (Sandbox Code Playgroud)
但我收到了一个 lint 警告:
Attribute autoVerify is only used in API 23 and higher (current min is 16)
Run Code Online (Sandbox Code Playgroud)
所以我把它改成这样(根据android studio给我的建议):
<intent-filter android:autoVerify="true" tools:targetApi="M">
Run Code Online (Sandbox Code Playgroud)
然后我在构建 apk 时收到此错误:
Error:java.lang.RuntimeException: [path_to_manifest]/AndroidManifest.xml:58:13-67:29: Error: Invalid instruction 'targetApi', valid instructions are : REMOVE,REPLACE,STRICT
Caused by: java.lang.IllegalArgumentException: No enum constant com.android.manifmerger.AttributeOperationType.TARGETAPI
Run Code Online (Sandbox Code Playgroud)
如何在消除 lint 警告的同时消除此错误?
编辑:我尝试了“清理项目”和“使缓存无效并重新启动” - 两者都无法解决错误。
在问题跟踪器上打开的问题:
android ×10
java ×4
android-collapsingtoolbarlayout ×1
applinks ×1
crashlytics ×1
fragment ×1
gradle ×1
history ×1
lint ×1
singleton ×1
uri ×1
url-scheme ×1