我有一个项目,它有2个产品口味和自己的目录:
的build.gradle:
android {
...
productFlavors {
free {
applicationId "com.sample.free"
buildConfigField "boolean", "free", "true"
}
paid {
applicationId "com.sample"
buildConfigField "boolean", "free", "false"
}
}
}
Run Code Online (Sandbox Code Playgroud)
我有一个类(例如PaidOperationClass
),仅用于paid
风味.所以,我把那个类放在src/paid/java
目录下.而且我有另一个类(例如CommonClass
),两种口味都使用它.所以我把它放在src/main/java
目录下:
src/main/ --> has CommonClass
src/free/
src/paid/ --> has PaidOperationClass
Run Code Online (Sandbox Code Playgroud)
在CommonClass
我有一个方法,如:
if(!BuildConfig.FREE) {
PaidOperationClass.doSomeStuff();
}
Run Code Online (Sandbox Code Playgroud)
因此PaidOperationClass
引用(具有导入)但从未被免费构建使用.
如果我为paid
味道构建应用程序,一切都很完美.但是,如果我尝试构建它的free
味道,它会失败,因为没有找到引用但不必要的类.如何在没有代码(类/方法)复制的情况下解决这个问题(例如将假人PaidOperationClass
置于free
风味之下)?是否有任何gradle选项在构建时忽略了这种构建错误?
编辑: 我需要一个不需要代码复制的gradle解决方案.基于注释的自定义脚本可能会在编译时删除不必要的产品风格代码.
我很难将列表项目放到房间里.列表项称为测量值,其类型为Measurement.列表项没有与数据库相关的主键.但如果有必要,我可以为ProductModel添加相同的主键.
这是我到目前为止:
@Entity(tableName = TABLE_NAME)
public class ProductModel {
public static final String TABLE_NAME = "product";
@PrimaryKey
private int idProduct;
private int idCategoryDefault;
@Relation(parentColumn = "idProduct", entityColumn = "idProduct", entity = SortedAttribute.class)
private List<SortedAttribute> sortedAttributes = null;
}
@Entity
public class SortedAttribute {
@PrimaryKey
private int idProduct;
private String reference;
@Embedded
private List<Measurement> measurements = null; //****how do i get this into room ? its a LIST of measurements, not a measurement so calling Embedded i think wont work as …
Run Code Online (Sandbox Code Playgroud) 我们可以在Google Play开发者控制台中为我们的Android应用(作为管理员)跟踪"评分和评论".我想知道是否有可能以编程方式获得这些"评级和评论"(即获得json或rss)?或者我应该尝试编写一个解析该页面的代码块?
编辑:我写了,我正在使用我的解析器.但我认为谷歌应该为此使用官方解决方案.
我正在使用Crashlytics for android,它确实帮我解决了很多崩溃问题.但是今天我遇到了一些问题.
当我试图在2.3.3 Galaxy S设备(通过wi-fi(带代理)连接到互联网)上测试crashlytics时,我在设备上看到了大约2:30分钟的黑屏.调试时; 我看到Crashlytics.start(this)
代码不是异步的.它等待建立连接,因此无法通过UI线程完成onCreate方法.(这解释了黑屏).
我知道这是一个代理问题(代理设置在2.3.x设备上有点错误)但等待大约2:30分钟使我的应用程序黑屏.这让我担心,这可能发生在任何其他现实生活条件,如互联网连接不良.
我将尝试将Crashlytics.start(this)
函数放入asynctask,并将在onCreate方法的每个活动上尝试这个.(AFAIK没有方法可以检查isCrashlyticsInitialized)
有没有人对此有更好的了解?
提前致谢.
logcat的:
10-02 16:01:38.410: D/Crashlytics(1561): Initializing Crashlytics 0.9.11.11
10-02 16:04:19.664: E/Crashlytics(1561): Network error while loading Crashlytics settings. Crashes will be cached until the network is available.
[URL=https://settings.crashlytics.com/api/v2/keys/KEY/platforms/android/apps/com.myapp/settings.json?libVersion=0.9.11.11&bundleVersion=441210&shortBundleVersion=2.1];[class java.net.SocketTimeoutException: Connection timed out]
Run Code Online (Sandbox Code Playgroud) 我一直在思考crouton,在创建了一个customView crouton popup后,我注意到了两件事; - 在创建时稍微修改了布局,如果视图更新,则会更正 - 无法添加样式来制作自定义烤面包片,或者我不知道...有人请提供一种方法来执行每个操作这些整齐
Crouton创建代码:
View crouton_view = getLayoutInflater().inflate(R.layout.crouton_layout, null);
Crouton Date_crounton = Crouton.make(this, crouton_view);
crouton_view.setBackgroundColor(Color.rgb(00, 153, 204));
Date_crounton.show();
Run Code Online (Sandbox Code Playgroud)
布局代码:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/crouton_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<EditText
android:layout_width="match_parent"
android:layout_height="50dp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<ImageView
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#b4b4b4" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<Button
android:id="@+id/crouton_cancel"
style="?android:attr/actionButtonStyle"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_weight="1"
android:gravity="center"
android:text="Cancel"
android:textSize="14sp" />
<ImageView
android:layout_width="1dp"
android:layout_height="30dp"
android:layout_gravity="center_vertical"
android:background="#b4b4b4" />
<Button
android:id="@+id/crouton_ok"
style="?android:attr/actionButtonStyle"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_weight="1"
android:gravity="center"
android:text="OK"
android:textSize="14sp" />
</LinearLayout>
<LinearLayout …
Run Code Online (Sandbox Code Playgroud) 我找到了构建一些输入框的代码,它们没问题,但在这段代码中它只是不起作用:
View.OnClickListener handleOnClick(final TextView textview) {
return new View.OnClickListener() {
public void onClick(View v) {
if(editOn==1){
textview.setText("neuer Text");
AlertDialog.Builder alert = new AlertDialog.Builder(this);
alert.setTitle("Hinzufügen");
alert.setMessage("Name des neuen Eintrags");
final EditText input = new EditText(this);
alert.setView(input);
alert.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
String entryInput = input.getText().toString();
loadUp(entryInput,"0","1.1.2000");
}
});
alert.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
}
});
}
}
};
}
Run Code Online (Sandbox Code Playgroud)
它说,"构造函数AlertDialog.Builder(new View.OnClickListener(){})未定义"每当我尝试插入一些东西"... new AlertDialog.Builder(this);, 那么我没有任何错误.我知道,"这个"必须引用一些东西.当我在menuitem上使用这个代码片段时,它运行良好,但我想在我激活编辑按钮时使用它(这就是if(editOn == 1)的意思)然后点击一个textview.我觉得这有点令人困惑,但我希望那里有人能理解我需要的东西并且可以帮助我!
android ×6
android-room ×1
build.gradle ×1
crashlytics ×1
crouton ×1
google-gdk ×1
google-glass ×1
google-play ×1
gradle ×1