この手順を参考に設定をする
Laravelの導入はこの手順
laravelプロジェクトをgithubからcloneしたら、以下を実施し、APP_DEYを生成する。
composer update
class CustomUIView: UIView {
init() {
super.init(frame: .zero)
// any initialization comes here...
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
}
ステップ1: main Storyboardを削除
ステップ2: Main Interface にある”Main”を削除
ステップ3: Info.plistのUISceneStoryboardFileとMainの記述を削除
ステップ4: SceneDelegateのfunc scene() を以下のように記述
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
guard let windowScene = (scene as? UIWindowScene) else { return }
window = UIWindow(frame: windowScene.coordinateSpace.bounds)
window?.windowScene = windowScene
window?.rootViewController = ViewController()
window?.makeKeyAndVisible()
}
ステップ5: ViewControllerにコードを記述開始
import UIKit
class ViewController: UIViewController {
let bannerHeight: CGFloat = 100.0
var viewWidth: CGFloat {
view.bounds.width
}
var viewHeight: CGFloat{
view.bounds.height
}
var topInset: CGFloat {
view.safeAreaInsets.top
}
var bottomInset: CGFloat {
view.safeAreaInsets.bottom
}
var appAreaHeight: CGFloat {
viewHeight - topInset - bottomInset - bannerHeight
}
lazy var first: UIView = {
let view = UIView()
view.backgroundColor = .red
return view
}()
lazy var second: UIView = {
let view = UIView()
view.backgroundColor = .blue
return view
}()
override func viewDidLoad() {
super.viewDidLoad()
view.backgroundColor = .white
view.addSubview(first)
view.addSubview(second)
}
override func viewWillLayoutSubviews() {
print("topInset: \(topInset)")
print("bottomInset: \(bottomInset)")
first.frame = CGRect(x: 0, y: topInset + bannerHeight, width: viewWidth, height: appAreaHeight/2)
second.frame = CGRect(x: 0, y: topInset + bannerHeight + appAreaHeight/2, width: viewWidth, height: appAreaHeight/2)
}
}
private ImageButton getCircleImageButton(int size, int resource) {
ImageButton button = new ImageButton(this);
GradientDrawable buttonGD = new GradientDrawable();
buttonGD.setSize(size, size);
buttonGD.setColor(Constant.appBackgroundColor);
buttonGD.setCornerRadius(size / 2);
buttonGD.setStroke(10, Constant.buttonLineColor);
button.setBackground(buttonGD);
button.setImageResource(resource);
button.setScaleType(ImageButton.ScaleType.FIT_CENTER);
button.setClipToOutline(true);
return button;
}
InputStreamは以下のコードでゲット出来る。
InputStream inputStream = getResources().openRawResource(R.raw.test);
int rawID = R.raw.class.getField("text").getInt(null);
import cn.sherlock.com.sun.media.sound.SF2Soundbank;
import cn.sherlock.com.sun.media.sound.SoftSynthesizer;
import jp.kshoji.javax.sound.midi.Instrument;
import jp.kshoji.javax.sound.midi.InvalidMidiDataException;
import jp.kshoji.javax.sound.midi.MidiUnavailableException;
SF2Soundbank drumsSF = new SF2Soundbank(mContext.getAssets().open("drums.sf2"));
SoftSynthesizer drums = new SoftSynthesizer();
metronome.loadAllInstruments(drumsSF);
for (int i = 0; i < drumsSF.getInstruments().length; i++) {
Instrument inst = drumsSF.getInstruments()[i];
Log.d("MyTest", "name" + inst.getName());
Log.d("MyTest", "bank" + inst.getPatch().getBank());
Log.d("MyTest", "program" + inst.getPatch().getProgram());
Log.d("MyTest", "==========");
}
// programChange(bank, program)
drums.getChannels()[0].programChange(0, 115);
import cn.sherlock.com.sun.media.sound.SF2Soundbank;
import cn.sherlock.com.sun.media.sound.SoftSynthesizer;
import jp.kshoji.javax.sound.midi.InvalidMidiDataException;
import jp.kshoji.javax.sound.midi.MidiSystem;
import jp.kshoji.javax.sound.midi.MidiUnavailableException;
import jp.kshoji.javax.sound.midi.Receiver;
import jp.kshoji.javax.sound.midi.ShortMessage;
// minimum setup for playing notes without using a Sequencer
// it plays random 3rd dyad each time
SF2Soundbank sf = new SF2Soundbank(getAssets().open("steinway.sf2"));
SoftSynthesizer synth = new SoftSynthesizer();
synth.open();
synth.loadAllInstruments(sf);
Receiver recv = synth.getReceiver;
ShortMessage msg = new ShortMessage();
int max = 72;
int min = 36;
int num = (int)Math.floor(Math.random()*(max-min)+min);
try {
msg.setMessage(ShortMessage.NOTE_ON, 0, num, 127);
recv.send(msg, synth.getMicrosecondPosition());
msg.setMessage(ShortMessage.NOTE_ON, 0, num+4, 127);
recv.send(msg, synth.getMicrosecondPosition());
}
https://learn.udacity.com/courses/ud867
Udacityの無料コースでGradleの基本を学んでみた
手順:
AndroidのMidiDriverをBuildしてみた
https://github.com/KyoSherlock/MidiDriver
// まずはterminalでbuild
$ ./gradlew
// this error occurs
// * What went wrong:
// Could not determine java version from '11.0.11'.
// then, this error occurs
// Gradle version 2.2 is required. Current version is 7.5. If using the gradle wrapper, try editing the distributionUrl in /Users/{your_user_name}/.gradle/daemon/7.5/gradle/wrapper/gradle-wrapper.properties to gradle-2.2-all.zip
// tried editing distributionUrl in gradle/wrapper/gradle-wrapper.properties
// distributionUrl=https\://services.gradle.org/distributions/gradle-2.2-all.zip
// and click "Try Again"
// then, this shows
// This version of Android Studio requires projects to use Gradle 4.8.1 or newer. This project is using Gradle 2.2.
Change to minimum versions (plugin 3.2.0, Gradle 4.8.1) and sync project
Change to latest versions (plugin 7.1.2, Gradle 7.2) and sync project
Open build file
// I chose "Change to minimum versions and sync project"
// and it works!
その後、./gradlew buildを実行すると、下記エラーメッセージ
> Task :sample:checkDebugClasspath FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Could not resolve all files for configuration ':sample:debugCompileClasspath'.
> Could not find com.android.support:appcompat-v7:23.1.1.
Searched in the following locations:
- file:/Users/{username}/Library/Android/sdk/extras/m2repository/com/android/support/appcompat-v7/23.1.1/appcompat-v7-23.1.1.pom
- file:/Users/{username}/Library/Android/sdk/extras/m2repository/com/android/support/appcompat-v7/23.1.1/appcompat-v7-23.1.1.jar
- file:/Users/{username}/Library/Android/sdk/extras/google/m2repository/com/android/support/appcompat-v7/23.1.1/appcompat-v7-23.1.1.pom
- file:/Users/{username}/Library/Android/sdk/extras/google/m2repository/com/android/support/appcompat-v7/23.1.1/appcompat-v7-23.1.1.jar
- file:/Users/{username}/Library/Android/sdk/extras/android/m2repository/com/android/support/appcompat-v7/23.1.1/appcompat-v7-23.1.1.pom
- file:/Users/{username}/Library/Android/sdk/extras/android/m2repository/com/android/support/appcompat-v7/23.1.1/appcompat-v7-23.1.1.jar
- https://jcenter.bintray.com/com/android/support/appcompat-v7/23.1.1/appcompat-v7-23.1.1.pom
- https://jcenter.bintray.com/com/android/support/appcompat-v7/23.1.1/appcompat-v7-23.1.1.jar
Required by:
project :sample
> Could not find com.android.support:design:23.1.1.
Searched in the following locations:
- file:/Users/{username}/Library/Android/sdk/extras/m2repository/com/android/support/design/23.1.1/design-23.1.1.pom
- file:/Users/{username}/Library/Android/sdk/extras/m2repository/com/android/support/design/23.1.1/design-23.1.1.jar
- file:/Users/{username}/Library/Android/sdk/extras/google/m2repository/com/android/support/design/23.1.1/design-23.1.1.pom
- file:/Users/{username}/Library/Android/sdk/extras/google/m2repository/com/android/support/design/23.1.1/design-23.1.1.jar
- file:/Users/{username}/Library/Android/sdk/extras/android/m2repository/com/android/support/design/23.1.1/design-23.1.1.pom
- file:/Users/{username}/Library/Android/sdk/extras/android/m2repository/com/android/support/design/23.1.1/design-23.1.1.jar
- https://jcenter.bintray.com/com/android/support/design/23.1.1/design-23.1.1.pom
- https://jcenter.bintray.com/com/android/support/design/23.1.1/design-23.1.1.jar
Required by:
project :sample
> Could not find com.android.support:support-v4:23.1.1.
Searched in the following locations:
- file:/Users/{username}/Library/Android/sdk/extras/m2repository/com/android/support/support-v4/23.1.1/support-v4-23.1.1.pom
- file:/Users/{username}/Library/Android/sdk/extras/m2repository/com/android/support/support-v4/23.1.1/support-v4-23.1.1.jar
- file:/Users/{username}/Library/Android/sdk/extras/google/m2repository/com/android/support/support-v4/23.1.1/support-v4-23.1.1.pom
- file:/Users/{username}/Library/Android/sdk/extras/google/m2repository/com/android/support/support-v4/23.1.1/support-v4-23.1.1.jar
- file:/Users/{username}/Library/Android/sdk/extras/android/m2repository/com/android/support/support-v4/23.1.1/support-v4-23.1.1.pom
- file:/Users/{username}/Library/Android/sdk/extras/android/m2repository/com/android/support/support-v4/23.1.1/support-v4-23.1.1.jar
- https://jcenter.bintray.com/com/android/support/support-v4/23.1.1/support-v4-23.1.1.pom
- https://jcenter.bintray.com/com/android/support/support-v4/23.1.1/support-v4-23.1.1.jar
Required by:
project :sample > project :sherlockmidi
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 3s
1 actionable task: 1 executed
StackOverflowにこんな情報がありました。
https://stackoverflow.com/questions/64286734/could-not-find-com-android-supportappcompat-v723-1-1
つまり、google()はGradle4.x+から登場したmaven{ url ‘https://maven.google.com’ }のショートカットで、それより古いGradleを使う場合はmavenと記載しないといけないということのようです。
// build.gradle
buildscript {
repositories {
jcenter()
google()
maven {
url 'https://maven.google.com/'
name 'Google'
}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
maven {
url 'https://maven.google.com/'
name 'Google'
}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
./gradlew buildでbuildされたarrファイルをlibs dir下にペースト
// build.gradle
dependencies {
implementation files('libs/sherlockmidi-release.aar')
}
$ ./gradlew
このようなエラーが出た場合
* What went wrong:
Could not determine java version from '11.0.11'.
対処法
$ gradle --version
------------------------------------------------------------
Gradle 7.5
------------------------------------------------------------
$ gradle wrapper --gradle-version=7.5