小编Den*_*ski的帖子

无法使用Android Studio 3.0 + DataBinding + Kotlin构建项目

我有一个庞大的项目,包括数据绑定,kotlin,匕首.我花了几天时间尝试使用几个stackoverflow的解决方案来构建它,并决定亲自询问它.

我假设一些第三方库使用数据绑定,因为添加此行没有帮助.

kapt 'com.android.databinding:compiler:3.0.0'
Run Code Online (Sandbox Code Playgroud)

Android Studio说:

'androidProcessor'依赖关系不会被识别为kapt注释处理器.请将配置名称更改为'kapt'以获取这些工件:'com.android.databinding:compiler:3.0.0'.

我尝试了什么,它没有帮助:

   kapt {
    generateStubs = true
}
Run Code Online (Sandbox Code Playgroud)

在local.properties中: kotlin.incremental=false

另一个SO解决方案没有帮助:

kapt ('com.android.databinding:compiler:3.0.0'){
        force = true
    }
Run Code Online (Sandbox Code Playgroud)

我的build.gradle

 apply plugin: 'com.android.application'

apply plugin: 'kotlin-android'
apply plugin: 'blockcanaryex'
apply plugin: 'kotlin-kapt'
apply plugin: 'newrelic'
apply plugin: 'kotlin-android-extensions'

def props = new Properties()
file("newrelic.properties").withInputStream { props.load(it) }

android {
    compileSdkVersion 26
    buildToolsVersion '26.0.2'
    applicationVariants.all { variant ->
        variant.outputs.each { output ->
            def stdout = new ByteArrayOutputStream()
            exec {
                commandLine "git", "symbolic-ref", "--short", "HEAD"
                standardOutput …
Run Code Online (Sandbox Code Playgroud)

data-binding android kotlin android-studio-3.0

38
推荐指数
1
解决办法
1万
查看次数

Facebook SDK中几乎没有内存泄漏

我试图为我的应用程序制作社交模块,类似于包装器,它将包含Google +,Facebook和Twitter集成模板.

现在我正在使用Facebook SDK并决定在我的应用程序中使用LeakCanary,在成功登录后我将设备旋转几次,并查看以下信息:

在此输入图像描述

这是MainActivity.class:

public class MainActivity extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    ButterKnife.bind(this);
    setFragment();

}
private void setFragment(){
    getSupportFragmentManager()
            .beginTransaction()
            .add(R.id.container, new MainFragment())
            .commit();
}
}
Run Code Online (Sandbox Code Playgroud)

以下是我登录Facebook的方式:

 public void configureFacebook(@NonNull Fragment fragment,
                              @Nullable String permissions, @Nullable String requestFields) {
    setPermissionAndRequestFields(permissions, requestFields);
    loginManager = LoginManager.getInstance();
    callbackManager = CallbackManager.Factory.create();
    loginManager.registerCallback(callbackManager, facebookCallback);
    loginManager.logInWithReadPermissions(fragment, Arrays.asList(this.permissions));
    loginManager=null;

}
Run Code Online (Sandbox Code Playgroud)

我尝试使用登录按钮登录,在这种情况下,我抓住了这个问题和新的问题,并提供以下信息:

在此输入图像描述

以下是我使用LoginButton.class登录的方法:

  public void configureFacebook(@NonNull Fragment fragment,
                              @Nullable String permissions, @Nullable String requestFields, @NonNull LoginButton button) {
    callbackManager = CallbackManager.Factory.create(); …
Run Code Online (Sandbox Code Playgroud)

android memory-leaks facebook-android-sdk

10
推荐指数
1
解决办法
1332
查看次数

默认值:setPolicyDataEnable(enabled = true)是什么?

我写了一个时间跟踪应用程序,在logcat中经常可以看到:

2028-2070/? D/MobileDataStateTracker? default: setPolicyDataEnable(enabled=true)
05-04 04:02:25.140    2028-2070/? D/MobileDataStateTracker? default: setPolicyDataEnable(enabled=true)
05-04 04:02:40.192    2028-2070/? D/MobileDataStateTracker? default: setPolicyDataEnable(enabled=true)
05-04 04:02:53.216    2028-2070/? D/MobileDataStateTracker? default: setPolicyDataEnable(enabled=true)
05-04 04:02:54.128    3575-3575/? D/dalvikvm? GC_FOR_ALLOC freed 1094K, 19% free 6781K/8288K, paused 4ms, total 4ms
05-04 04:02:55.468    3575-3575/? I/Choreographer? Skipped 80 frames!  The application may be doing too much work on its main thread.
05-04 04:02:56.524    2028-2070/? D/MobileDataStateTracker? default: setPolicyDataEnable(enabled=true)
05-04 04:03:08.504    2028-2070/? D/MobileDataStateTracker? default: setPolicyDataEnable(enabled=true)
05-04 04:03:19.584    2028-2070/? D/MobileDataStateTracker? default: setPolicyDataEnable(enabled=true)
05-04 04:03:23.792        65-65/? D/Genyd? Received Set …
Run Code Online (Sandbox Code Playgroud)

java android

5
推荐指数
0
解决办法
1354
查看次数

如何显示谷歌自定义搜索结果的下一页?

我知道SOF有很多类似的问题,但我没有找到对我有用的东西.根据Google Custom Search文档,&start参数:

The start parameter uses a zero-based index, meaning the first result is 0, the second result is 1 and so forth.

The start parameter works in conjunction with the num parameter to determine which search results to return. 
Run Code Online (Sandbox Code Playgroud)

我尝试从零发送,但应用程序崩溃.在这次尝试中我尝试发送:

为1页: &num=10&start=1

2页: &num=10&start=11

但它仍然要求1页.&start参数始终被忽略

我正在写一个Android应用程序,它进行图像搜索,在向下滚动它应该在下一页(下10个图像),在android 它总是返回1页有10个图像,我在浏览器中测试请求,withount &num参数,它的工作原理.在Android上,似乎在第一页加载后,参数&start&num被忽略.

我使用robospice与改造相结合,我无法弄清楚如何获取请求字符串,也许我做错了什么

这是我的界面:

 public static final String BASE_URL = "https://www.googleapis.com/customsearch";
public static final String API_KEY = "AIzaSyCCuxxVLzm2sZP-adhRNYKeSck1mMMgsAM";
public static …
Run Code Online (Sandbox Code Playgroud)

java rest android google-custom-search

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

如何根据当前位置设置正确的Lat和Lng

我的目标是使用Google Places API进行自动完成预测,现在我想制作一些将采用当前位置lat和lng的算法,并预测直径仅为100-200 km的地方.

那么,此时我得到用户当前位置lat和lng,如何设置100-200 km?

 private void getCurrentLocation() {
    mLastLocation = LocationServices.FusedLocationApi
            .getLastLocation(mGoogleApiClient);
    if (mLastLocation != null) {
        double latitude = mLastLocation.getLatitude();
        double longitude = mLastLocation.getLongitude();
        mLatLonBounds = new LatLngBounds(new LatLng(latitude,longitude),
                                  new LatLng(latitude,longitude));
        Log.d("myTag","lat = "+mLatLonBounds.northeast.latitude+" ,lon = "+mLatLonBounds.northeast.longitude);
        //Log.d("myTag","lat = "+mLatLonBounds.southwest.latitude+" ,lon = "+mLatLonBounds.southwest.longitude);

    }else {
        //some code
    }
}
Run Code Online (Sandbox Code Playgroud)

以下是我如何设置自动预测的界限:

  @Nullable
private ArrayList<AutoCompletePlace> getAutocomplete(CharSequence constraint) {
    if (mGoogleApiClient.isConnected()) {
        Log.i(Constants.AUTO_COMPLETE_TAG, "Starting autocomplete query for: " + constraint);

        // Submit the query to the autocomplete API and retrieve …
Run Code Online (Sandbox Code Playgroud)

android geolocation google-places-api

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

带有Kotlin的Dagger 2,在ApplicationComponent中返回带泛型的类型

我想返回带有泛型的类型,通过子图公开,问题出在自动生成的java类中,我试着做一些事情,但解决它的一种方法是从AppComponent中删除泛型类型并返回简单对象.有更"正确"的方法吗?

这是AppComponent

@Singleton
@Component(modules = arrayOf(ApplicationModule::class))
interface ApplicationComponent {
    fun inject(activity: BaseActivity<MvpView, MvpPresenter<MvpView>>)

    //...
    fun dataBase(): Database<Realm>
}
Run Code Online (Sandbox Code Playgroud)

这是ApplicationModule中的函数

@Provides @Singleton fun provideDatabase(@AppContext context: App): Database<Realm> {
    Realm.init(context)
    val config = RealmConfiguration.Builder()
            .deleteRealmIfMigrationNeeded()
            .name("db")
            .build()
    Realm.setDefaultConfiguration(config)
    return RealmDatabase(Realm.getDefaultInstance())
}
Run Code Online (Sandbox Code Playgroud)

然后我想收到我的数据库

@Provides @ActivityScope fun provideDich(database: Database<Realm>) = Someobject(database)
Run Code Online (Sandbox Code Playgroud)

然后我看到日志说:

**Error:com.test.data.storage.Database<? extends io.realm.Realm> cannot be provided without an @Provides-annotated method.**
Run Code Online (Sandbox Code Playgroud)

因为dagger2生成这样的工厂并且有java掩码

    public final class Logout_Factory implements Factory<Logout> {
  private final MembersInjector<Logout> logoutMembersInjector;

  private final Provider<SessionStorage.CloudStorage> arg0Provider;

  private final Provider<Database<? extends Realm>> arg1Provider; …
Run Code Online (Sandbox Code Playgroud)

java generics android kotlin dagger-2

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

Google Maps v2授权失败.不同的SHA1

我已经阅读了所有类似的问题并完成了其中描述的所有内容,但没有帮助.

Google Maps API v2已启用且API密钥正确无误

我刚刚在"新项目"中选择了GoogleMapsActivity,然后创建了一个key.jks,通过keytool创建了sha1,创建了公共api访问密钥,将我的API密钥放入了清单.

我试过:clean-rebuild-unistall app-install
多次更新api密钥
用new key.jks创建一个新项目(并且一遍又一遍)
删除并创建api密钥

这是我的清单:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.dandewine.user.thinkmobiletest" >

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<!--
Run Code Online (Sandbox Code Playgroud)

使用Google Maps Android API v2不需要ACCESS_COARSE/FINE_LOCATION权限,但建议使用这些权限. - >

<application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
    <meta-data
        android:name="com.google.android.gms.version"
        android:value="@integer/google_play_services_version" />
    <meta-data
        android:name="com.google.android.maps.v2.API_KEY"
        android:value="AIza**************************" />

    <activity
        android:name=".ActivityMain"
        android:label="@string/title_activity_activity_main" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
</application>
Run Code Online (Sandbox Code Playgroud)

这是我的活动:

public class ActivityMain extends FragmentActivity implements OnMapReadyCallback {


@Override
protected void onCreate(Bundle savedInstanceState) { …
Run Code Online (Sandbox Code Playgroud)

android google-maps

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

godep:exec:“执行”:在$ PATH中找不到可执行文件

我试图在heroku上部署服务器,但我停留在应该使用Godep的步骤上,我花了很少的时间在GO上,最近两天我一直在寻找如何解决此问题的方法,实际上这是一个很受欢迎的问题,但是我无法确定出来,也许我做错了什么。

我有OS X 10.11.2
我的GOPATH-用户/ denis / Programming / Golang
我的路径-$ GOPATH / bin
我试图对放在$ GOPATH / src / backend中的项目使用godep

在我的PATH中,我有一个可执行的Godep文件(不是.go)。

我工作场所的整体结构。

/Golang/
     .bin/
        godep //executable file
     .pkg/
        .darwin-amd64/
             .//other folders/
     .src/
         .github.com/
         .backend/
         .//other folders// 
Run Code Online (Sandbox Code Playgroud)

heroku go

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

未捕获的翻译错误:com.android.dx.cf.code.SimException:local 0007:invalid

我不使用Proguard.该项目正在成功构建,但当我尝试在设备上运行时,它显示此错误.我在Android Studio 3.0中使用Kotlin项目工作,这真的很糟糕.我决定切换回2.3 AS,但问题仍然是一样的.日志较小但异常文本相同.

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'
apply plugin: 'kotlin-android-extensions'

tasks.withType(JavaCompile) {
    options.fork = true
    options.incremental = true
}

android {
    def rootProject = rootProject.ext

    compileSdkVersion rootProject.compileSdkVersion
    buildToolsVersion rootProject.buildToolsVersion
    defaultConfig {
        minSdkVersion rootProject.minSdkVersion
        targetSdkVersion rootProject.targetSdkVersion
        versionCode rootProject.versionCode
        versionName rootProject.versionName
        testInstrumentationRunner rootProject.testInstrumentationRunner
        vectorDrawables.useSupportLibrary = true
       // multiDexEnabled true
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
        debug {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    productFlavors {
        //flavorDimensions "content"
        production { …
Run Code Online (Sandbox Code Playgroud)

android gradle kotlin

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

如何增加BottomBar中项目之间的距离?

我想使用浮动操作按钮制作完全相同的底部栏。我已经使用了standart BottomNavigationView以及该,但是无法增加项目之间的距离。有没有办法做到这一点?

在此处输入图片说明

在此处输入图片说明

android bottombar

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

如何在RelativeLayout中叠加视图?

是我所拥有的:

是否可以以某种方式降低按钮覆盖层,但不更改布局。我正在使用相对。问题是当按钮转到数字的行位置时,按钮的一小部分不可见。

这里的 .xml 片段:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:materialdesign="http://schemas.android.com/apk/res-auto"
xmlns:fab="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="65dp"
android:orientation="vertical"
android:padding="8dp"
android:background="@drawable/shadow_listitem">

<TextView android:layout_width="wrap_content" android:layout_height="wrap_content"
          android:textAppearance="?android:attr/textAppearanceLarge" android:text="Task is Finish!"
          android:id="@+id/txtFinish"
          android:visibility="gone"

          android:layout_alignBottom="@+id/tvDays"
          android:layout_alignParentLeft="true"
          android:layout_alignParentStart="true"/>
<TextView android:layout_width="wrap_content"
          android:layout_height="wrap_content"

          android:textAppearance="?android:attr/textAppearanceLarge" android:text="Name" android:id="@+id/tvName"
          android:layout_alignParentTop="true"
          android:layout_alignParentRight="true"
          android:layout_alignParentEnd="true"/>
<TextView android:layout_width="wrap_content" android:layout_height="wrap_content"
          android:textAppearance="?android:attr/textAppearanceSmall"
          android:layout_marginLeft="-27dp"
          android:text="0000" android:id="@+id/tvDays"
          android:layout_alignTop="@+id/textView4"
          android:layout_toLeftOf="@+id/textView4"
          android:layout_toStartOf="@+id/textView4"/>

<TextView android:layout_width="wrap_content" android:layout_height="wrap_content"
          android:textAppearance="?android:attr/textAppearanceSmall" android:text="00" android:id="@+id/tvHours"
          android:layout_toLeftOf="@+id/textView2"
          android:layout_toStartOf="@+id/textView2"
          android:layout_below="@+id/tvName"/>

<TextView android:layout_width="wrap_content" android:layout_height="wrap_content"
          android:textAppearance="?android:attr/textAppearanceSmall" android:text="00" android:id="@+id/tvMinutes"

          android:layout_alignTop="@+id/textView8"
          android:layout_toLeftOf="@+id/textView8"
          android:layout_toStartOf="@+id/textView8"/>
<TextView android:layout_width="wrap_content" android:layout_height="wrap_content"
          android:textAppearance="?android:attr/textAppearanceSmall" android:text=":" android:id="@+id/textView8"
          android:layout_alignTop="@+id/tvSeconds"
          android:layout_toLeftOf="@+id/tvSeconds"
          android:layout_toStartOf="@+id/tvSeconds"/>
<TextView android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:textAppearance="?android:attr/textAppearanceSmall" android:text="00" android:id="@+id/tvSeconds"

          android:layout_below="@+id/tvName" …
Run Code Online (Sandbox Code Playgroud)

xml android listview

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