Gradle似乎在我正在处理的项目中丢失了构建类型。我可以重新创建一个小问题,如下所示。我有以下文件:
import
的build.gradle:
build.gradle
local.properties
src/main/AndroidManifest.xml
local.properties:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:+'
}
}
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
minSdkVersion 1
targetSdkVersion 23
}
buildTypes {
debug {
}
release {
}
}
}
src / main / AndroidManifest.xml:
sdk.dir=/path/to/android-sdk-linux
我希望Gradle生成任务<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="example"/>
和installDebug
,因为我将installRelease
和debug
定义为release
。但事实并非如此。命令buildTypes
产生:
gradle tasks
出了什么问题?为什么任务:tasks
------------------------------------------------------------
All tasks runnable from root project
------------------------------------------------------------
...
Install tasks
-------------
installDebug - Installs the Debug build.
installDebugAndroidTest - Installs the android (on device) tests for the Debug build.
uninstallAll - Uninstall all applications.
uninstallDebug - Uninstalls the Debug build.
uninstallDebugAndroidTest - Uninstalls the android (on device) tests for the Debug build.
uninstallRelease - Uninstalls the Release build.
Verification tasks
------------------
...
不可用?
答案 0 :(得分:13)
首先要发布,您需要在根项目中创建 == CONTROLLER
controllers/users_controller.rb
class UsersController < ApplicationController
def new
@user = User.new
render partial: 'users/new_form_content', layout: false
end
def user_params
params.require(:user).permit(:email, :password, profile_attributes: [:first_name, :last_name])
end
...
end
== MODELS
models/user.rb
class User < ActiveRecord::Base
has_one :profile
accepts_nested_attributes_for :profile
end
class Profile < ActiveRecord::Base
belongs_to :user
end
== VIEW
users/new_form_content.rb
<div>
...
<%= form_for @user, remote: true, ... do |f| %>
<%= f.fields_for :profile do |profile_form| %>
<%= profile_form.text_field :last_name %>
<%= profile_form.text_field :first_name %>
<% end %>
...
<%= f.text_field :email %>
<%= f.text_field :password %>
<%= f.text_field :password_confirmation %>
...
<% end %>
...
</div>
。
您需要在build.gradle中提供这些详细信息。
您可以创建两个keystore
调试&amp;如果你愿意,可以释放它们。
最后在signingConfigs
链接到那个。
buildTypes
然后在android {
signingConfigs {
debug {
keyAlias 'alias'
keyPassword 'password'
storeFile file('../xyz.jks')
storePassword 'password'
}
}
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
minSdkVersion 1
targetSdkVersion 23
}
buildTypes {
debug {
signingConfig signingConfigs.debug
}
release {
signingConfig signingConfigs.debug
}
}
任务
installRelease
希望这对你有所帮助。
答案 1 :(得分:0)
对于边缘情况,当您不打算发布应用程序时(例如测试混淆的apk),您可以跳过使用生产密钥进行签名,甚至更简单:
android {
signingConfigs {
debug {}
}
buildTypes {
debug {
signingConfig signingConfigs.debug
}
release {
signingConfig signingConfigs.debug
}
}